Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Adding the possibility of use in projects with different domains. #59

Closed
mlg1 opened this issue Aug 12, 2020 · 3 comments
Closed

Comments

@mlg1
Copy link

mlg1 commented Aug 12, 2020

Hello,
By changing one line, functionality can be added to use the plugin with different domains.

In the file src/Cache.php on line 198:

- $segments = explode('/', ltrim($request->getPathInfo(), '/'));
+ $segments = explode('/', ltrim($request->getHost() . $request->getPathInfo(), '/'));

It has been tested on Laravel 7 and it works for me. Is it a good idea? Is there something I'm missing?

@mlg1
Copy link
Author

mlg1 commented Aug 12, 2020

I also forgot to add the .htaccess file.

# Serve Cached Page If Available...
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/page-cache/%{HTTP_HOST}/pc__index__pc.html -f
RewriteRule .? page-cache/%{HTTP_HOST}/pc__index__pc.html [L]
RewriteCond %{DOCUMENT_ROOT}/page-cache/%{HTTP_HOST}%{REQUEST_URI}.html -f
RewriteRule . page-cache/%{HTTP_HOST}%{REQUEST_URI}.html [L]
RewriteCond %{DOCUMENT_ROOT}/page-cache/%{HTTP_HOST}%{REQUEST_URI}.json -f	
RewriteRule . page-cache/%{HTTP_HOST}%{REQUEST_URI}.json [L]

@JosephSilber
Copy link
Owner

This would break all existing caches.

If you want this in your project, you can easily extend the built-in Cache class, and overwrite that method 👍

@MarcosBL
Copy link

You can also do it setting a different path depending on domain at boot on AppServiceProvider

Look here #74 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants