Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess url掩蔽修改重写_.htaccess_Url_Mod Rewrite_Masking - Fatal编程技术网

.htaccess htaccess url掩蔽修改重写

.htaccess htaccess url掩蔽修改重写,.htaccess,url,mod-rewrite,masking,.htaccess,Url,Mod Rewrite,Masking,我做了一些URL屏蔽,一切都很好。我现在正试图解决一个问题: RewriteRule ^(.*)/(.*)/clubs/(.*)/$ teams.php?competition=$1&season=$2&teamid=$3 通过以上内容,我可以通过两种方式访问相同的页面,www.domain.com/premier league/2010-2011/arsenal/和www.domain.com?competition=premier league&seasure=2010-2

我做了一些URL屏蔽,一切都很好。我现在正试图解决一个问题:

RewriteRule ^(.*)/(.*)/clubs/(.*)/$ teams.php?competition=$1&season=$2&teamid=$3
通过以上内容,我可以通过两种方式访问相同的页面,
www.domain.com/premier league/2010-2011/arsenal/
www.domain.com?competition=premier league&seasure=2010-2011&teamid=arsenal

在我的重写规则中是否有一种方法可以重定向URL(理想情况下为301)是否有人通过不整洁的方式进行了此操作“
www.domain.com?competition=premier league&season=2010-2011&teamid=arsenal


提前感谢

如果在此规则之后添加另一条与“反向”模式匹配的重写规则,并将这两条规则都标记为[L]ast规则,则可能会起作用。我首先重写url以包含查询字符串,然后将该字符串链接到下一个规则。之后,我们[R]编辑浏览器

RewriteRule ^(.)/(.)/clubs/(.*)/$ teams.php?competition=$1&season=$2&teamid=$3 [L]
RewriteRule ^(.+) $1%{QUERY_STRING} [C]
RewriteRule ^teams.php?competition=([a-zA-Z0-9]+)&season=([a-zA-Z0-9]+)&teamid=([a-zA-Z0-9]+)$ $1/$2/clubs/$3/ [R=301,L]
注意,我没有测试这个规则或第二条规则的正则表达式。可能需要稍微调整字符范围。另外,我还没有在第二条规则中测试查询字符串重写


编辑:有关
mod_rewrite
的一些常见用例,请参见此处:

对不起,但是
RewriteRule
不能以这种方式处理查询字符串。有没有一种方法可以将所有页面从我的旧站点重定向到我的新域主页?啊,很明显!您需要使用重写链将其追加。让我检查一下是否有效…@Richard G,检查一下我刚刚发布的链接: