htaccess重定向与错误的格式化查询字符串

时间:2015-04-28 00:20:05

标签: regex .htaccess redirect url-rewriting query-string

我正在尝试使用joomla生成的格式错误的查询字符串重定向网址。

网址/index.php?/Some-String/(请注意缺少常规参数?x=)以下内容之一:

/some-string

/index.php?q=/Some-String/

我试过Redirect 301 /index.php?/Some-String/ /some-string 但我得到了重定向到/?%2FSome-String%2F=

我还尝试将?/替换为?q=/但没有成功。

1 个答案:

答案 0 :(得分:0)

也许是这样的?

RewriteEngine On

RewriteCond {THE_REQUEST} \ /+index\.php\?(?:q=|)([^&\ ]+)
RewriteRule ^ /%1? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?q=$1 [L,QSA]