Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to redirect an entire duplicate directory to the same files in the directory above the dup_folder.

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

Is there something I can add to .htaccess to Rewrite the URL to how I want, or are the two above URLs seen as the exact same URL to a search engine?

share|improve this question
    
I think this URL has the answer: webmasters.stackexchange.com/questions/7539/… . I have mod_rewrite enabled. Any help with the regular expression is appreciated. –  JMC May 3 '11 at 18:03
add comment

1 Answer

up vote 1 down vote accepted

Something else is at play here, that is causing

http://www.example.biz/dup_folder/inspection11.htm

to be converted to

http://www.example.biz/inspection11.htm?q=dup_folder/inspection11.htm

because out of the box, the use of Redirect 301 should not add that query string.

So I'd look at the configuration of your site, the httpd.conf or the configuration of the relevant apache Vhost directive, or indeed existing .htaccess files, to see if you can stop whatever custom redirect process is adding the query string there.

If you can't (find or change), then the following rewrite rule in a .htaccess file under /dup_folder/ (assuming you remove the existing Redirect 301 ) should remove the query string.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/dup_folder/(.*)
RewriteRule .* /inspection11.htm? [R=301,L]

With the use of a trailing ? on the rewrite, it will clear off the query string that is being added by something else.

share|improve this answer
    
It's been a while since I was messing with this. I'll look back into it tomorrow. The site that had this issue uses a CMS that performs it's own re-writes. Thanks for posting. –  JMC Jun 1 '11 at 3:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.