开发者

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. 开发者_JS百科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? There are multiple files in the folder with various names.

Redirect Code in .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:

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 ? 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.

NC is used for ignore case comparison here


RewriteEngine on
RewriteRule ^/dup_folder/$ http://www.example.biz/inspection11.htm [r=301,l]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜