仅重写子文件夹而不是文件

时间:2016-10-03 13:25:09

标签: php regex apache .htaccess mod-rewrite

我想要实现的是构建像/ profile1 / profile2等的URL。哪个重写为profile.php?id = profile1

我目前使用的代码是

RewriteRule  ^(.+)$              profile.php?p=$1    [NC,QSA,L]

它按预期工作但问题是它还重写了像/sp.php?e=mybids这样的网址

那些网址也被重定向到profile.php,我不希望它发生。

任何帮助?

2 个答案:

答案 0 :(得分:0)

RewriteRule ^([^\.]+)$ profile.php?p=$1 [NC,QSA,L]

答案 1 :(得分:0)

您可以检查文件是否不存在,然后重定向到profile.php:

previousRsp
祝你好运

相关问题