问题
I am looking for a way to get rid off the .php extension from my file i have just got a static website with index.php and map.php
I have tried lots of different tutorials but none work i just want the following.
http://example.co.uk/map.php becomes http://example.co.uk/map/
and
http://example.co.uk/index.php becomes http://example.co.uk/
Can you do this with a static file i have tried so many different options and none have worked for me.
i have tried this.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^map/(.*)/$ map.php
Any help please.
回答1:
Try this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^map/?$ map.php [NC,QSA,L]
RewriteCond %{SCRIPT_FILENAME} \/index\.php [NC]
RewriteRule (.*) http://www.domain.com/ [R=301,L]
# if you have more than one file like map, you can use this
# this will redirect everything to .php like: test/ => test.php
# RewriteRule ^([a-z0-9_\-]+)/?$ $1.php [NC,QSA,L]
来源:https://stackoverflow.com/questions/8053938/htaccess-to-create-search-engine-friendly-urls