: Htacess seems to make the page load forever I need to rewrite a URL of my server so the URL looks friendly. Like: site.com/var1/var2/var3/... to site.com/index.php?page=var1/var2/var3/... So I
I need to rewrite a URL of my server so the URL looks friendly. Like:
site.com/var1/var2/var3/...
to
site.com/index.php?page=var1/var2/var3/...
So I wrote this .htacess:
RewriteEngine On
RewriteRule ^.*$ index.php?page= [NC,L]
But when I upload it to the server, and try to load a page, the page loads forever! What am I doing wrong?
More posts by @Deb1703797
1 Comments
Sorted by latest first Latest Oldest Best
RewriteRule ^.*$ index.php?page= [NC,L]
This will result in a rewrite loop. You are also not capturing the sub pattern, so will be empty. In order to prevent a rewrite loop, you need a get-out-clause, such as not rewriting when the request is already for index.php.
Something like:
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.php
RewriteRule ^(.*)$ /index.php?page= [NC,L]
Only when the request is not for /index.php will the RewriteRule be processed. The parenthesised sub pattern (.*) is stored in .
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.