Last active
September 6, 2024 18:36
-
-
Save davemackintosh/8ac35fff747dbf2c95e1 to your computer and use it in GitHub Desktop.
Working .htaccess for Single Page Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ifModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule (.*) /index.html [QSA,L] | |
</ifModule> |
hi, I need to redirect using the parameters, do you know how I can do?
The problem is that if I redirect to index, in the canonical name I lose the parameters and for the seo, it is not a good thing.
so, for example
If I use this rule:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /auto [QSA,L]
if my input url is https://myserver.com/auto/alfaromeo and i redirect to auto,
the page is correct, but the canonical name is
https://myserver.com/auto/
is there a way to pass the parameter, too?
Thanks a lot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi my friend, go this routes : /etc/apache2/sites-enabled/000-default.conf And add the following code :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.html$ - [L]
RewriteCond /var/www/html/%{REQUEST_FILENAME} !-f
RewriteCond /var/www/html/%{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
It must be done.