htaccess的重定向不工作与参数的URL重定向、参数、工作、htaccess

由网友(饮了晚风)分享简介:我要重定向的index.php行动=这与放大器;?ID = 1到index.php行动=这与放大器;?ID = 2 I want to redirect index.php?action=this&id=1 to index.php?action=this&id=2我试过code低于我的.htaccess,但它并没...

我要重定向的index.php行动=这与放大器;?ID = 1到index.php行动=这与放大器;?ID = 2

I want to redirect index.php?action=this&id=1 to index.php?action=this&id=2

我试过code低于我的.htaccess,但它并没有帮助

I tried the code below in my .htaccess but it didn't help

redirect 301 index.php?action=this&id=1 http://mysite.com/index.php?action=this&id=2

我究竟做错了什么?这可能是一个解决办法?

What am i doing wrong here? what could be a workaround?

推荐答案

为了您有无可以使用的mod_rewrite ,以匹配特定的查询字符串。请检查是否已安装/让您的主机上。在这种情况下,规则将是这样的:

In order to match specific query string you have to use mod_rewrite. Please check if it is installed/allowed on your host. The rule in this case will be something like this:

# most likely be required for rewrite rules to function properly
Options +FollowSymLinks +SymLinksIfOwnerMatch

# Activate Rewrite Engine
RewriteEngine On
RewriteBase /

# actual rule
RewriteCond %{QUERY_STRING} ^action=this&id=1 [NC]
RewriteRule ^index.php$ /index.php?action=this&id=2 [R=301,L]

这需要放置在.htaccess在网站根目录。如果放在其他地方一些小的变化可能是必需的。

This needs to be placed in .htaccess in website root folder. If placed anywhere else some small changes may be required.

这条规则将仅重定向 /index.php?action=this&id=1 /index.php?action=this&id = 2 并没有其他网址(就像你在你的问题问)。

This rule will only redirect /index.php?action=this&id=1 to /index.php?action=this&id=2 and no other URLs (just as you asked in your question).

阅读全文

相关推荐

最新文章