如何使用带有问号的htaccess转发目录?

时间:2014-05-01 19:13:57

标签: regex apache .htaccess mod-rewrite rewrite

如何转发带有问号的目录?

我试图使用htaccess转发所有请求,但是我需要转发的网址中有一个问号,对于我的生活,我已经尝试了所有内容,但由于这一点无法获得任何工作问号。

我试图转发这个:

http://domain.com/index.php?/

对此:

http://domain.com/

我可以在我的htaccess中添加什么?

目标是使对此URL的旧引用自动转发到新的URL结构。例如:

旧网址结构

http://domain.com/index.php?/topic/

新网址结构:

http://domain.com/topic/

非常感谢任何帮助。

提前致谢。

1 个答案:

答案 0 :(得分:0)

将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+index\.php\?(/\S+) [NC]
RewriteRule ^ /%1? [R=301,L]