输入链接时重定向用户

时间:2014-02-26 23:18:57

标签: php regex apache .htaccess mod-rewrite

我知道还有其他帖子询问同一个问题,但我似乎无法让它们发挥作用。

当用户输入

http://mywebsite.com/msdns/[letters, numbers, and symbols here]

我需要它去我的页面:

http://mywebsite.com/msdns/index.php?q=[letters, numbers, and symbols here]

到目前为止,我的.htaccess文件(位于index.php所在的文件夹中)是这样的:

RewriteEngine On
RewriteRule ^/(.*)/$ /index.php?q=$1

然而,这不起作用。任何解决方案?

提前谢谢,拍拍

1 个答案:

答案 0 :(得分:3)

将此规则放在/msdns/.htaccess

RewriteEngine On
RewriteBase /msdns/

RewriteRule ^((?!index\.php).+)$ index.php?q=$1 [L,QSA]
相关问题