[英]Regular Expression to get rid of query string on URL rewriting dup folder
I'm redirecting an entire folder into the duplicate folder above it.我将整个文件夹重定向到它上面的重复文件夹中。 I have mod_rewrite enabled, what type of regular expression could I put in .htaccess to get rid of the: ?q=dup_folder/inspection11.htm
from the URL below?我启用了 mod_rewrite,我可以在 .htaccess 中放入什么类型的正则表达式来摆脱下面的 URL 中的: ?q=dup_folder/inspection11.htm
? There are multiple files in the folder with various names.文件夹中有多个不同名称的文件。
Redirect Code in .htaccess: .htaccess 中的重定向代码:
Redirect 301 /dup_folder/ http://www.example.biz/
It redirects to:它重定向到:
http://www.example.biz/inspection11.htm?q=dup_folder/inspection11.htm
But I want it to redirect to:但我希望它重定向到:
http://www.example.biz/inspection11.htm
Put these lines in your .htaccess file:将这些行放入您的 .htaccess 文件中:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteRule ^dup_folder/?$ http://www.example.biz/inspection11.htm? [R=301,L,NC]
It is important to end redirected URL with ?
用?
结束重定向的 URL 很重要to get rid of any query string you may have in original URI like dup_folder/?foo=bar
will be redirected to http://www.example.biz/inspection11.htm
discarding the original query string foo=bar
.要摆脱您在原始 URI 中可能拥有的任何查询字符串,例如dup_folder/?foo=bar
将被重定向到http://www.example.biz/inspection11.htm
丢弃原始查询字符串foo=bar
。
NC
is used for ignore case comparison here NC
在这里用于忽略大小写比较
RewriteEngine on
RewriteRule ^/dup_folder/$ http://www.example.biz/inspection11.htm [r=301,l]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.