I have links like these:
www.domain.com/page.php?id=1#info
I’d just like to hide the .php to get this:
www.domain.com/page?id=1#info
For this reason I found this .htaccess script:
RewriteEngine on
# to make `/path/index.php` to /path/
RewriteCond %{THE_REQUEST} ^GET\s(.*/)index\.php [NC]
RewriteRule . %1 [NE,R=301,L]
RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC]
RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC]
RewriteCond %{REQUEST_URI} !\.php$ [NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule . %{REQUEST_URI}.php [L]
This does exactly the job and works in all browser except safari, which will output:
www.domain.com/page?id=1
The #info is gone.
How could a browser interpret a .htaccess different? Can someone help me to write the correct .htaccess file?
Safari behaves the way every browser should:
In plain English: the part of the URL after the
#shouldn’t be sent to the server by the browser. The browser should handle this locally. This means that you might loose the fragment when you apply redirects (rewrite rules).