的.htaccess创建搜索引擎友好的URL [英] .htaccess to Create Search Engine-Friendly URLs
本文介绍了的.htaccess创建搜索引擎友好的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要寻找一种方式来摆脱掉PHP扩展从我的文件,我刚刚得到了一个静态的网站的index.php和map.php
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/
和
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.
我已经试过这一点。
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^map/(.*)/$ map.php
任何帮助,请。
Any help please.
推荐答案
试试这个
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]
这篇关于的.htaccess创建搜索引擎友好的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文