Mod_rewrite规则删除index.php [英] Mod_rewrite rule to remove index.php
本文介绍了Mod_rewrite规则删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要
site.com/index.php?s=super-smash-bros-baww-SUzohN
重定向到
site.com/super-smash-bros-baww-SUzohN
.
我该怎么做?
请注意,单词数可以不同,例如:/index.php?s=aaa-bbb-ccc
需要转到/aaa-bbb-ccc
Note that the number of words can be different e.g: /index.php?s=aaa-bbb-ccc
needs to go to /aaa-bbb-ccc
谢谢
推荐答案
尝试将以下内容添加到网站根目录中的.htaccess
文件中.
Try adding the following to the .htaccess
file in the root directory of your site.
RewriteEngine on
RewriteBase /
#redirect to remove index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?s=([^\ &]+) [NC]
RewriteRule ^ %1? [L,R=301]
#process the SEF Url with index.php
RewriteRule ^([-a-zA-Z]+)$ index.php?s=$1 [L]
这篇关于Mod_rewrite规则删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文