Forum Moderators: phranque

Message Too Old, No Replies

Removing directory -- need help with accompanying 301 redirect

         

ksolaro

1:56 am on Mar 10, 2010 (gmt 0)

10+ Year Member



I am restructuring a website that has good indexing in google, and need to make sure I have good 301 redirects in place.

The current site structure is like this:

http://www.example.com/store/foo/bar


The new site structure is like this:

http://www.example.com/foo/bar


Basically, the /store directory doesn't exist anymore.

This is the rule I tried writing in my .htaccess file and it isn't working. Admittedly, I am terrible at regex. Any guidance would be helpful.

rewriteCond %{REQUEST_URI} ^store$ [NC] 
rewriteRule ^store/(.*)$ http://www.example.com/$1 [R=301,L]

[edited by: jdMorgan at 6:32 am (utc) on Mar 10, 2010]
[edit reason] example.com [/edit]

jdMorgan

6:31 am on Mar 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like over-complication killed it. You do not need the RewriteCond (it is redundant), and your RewriteCond's pattern is end-anchored, making it an 'exact-match-required' rule.

Please do not link to "mysite.com" -- It is a live domain.

Jim

ksolaro

5:17 pm on Mar 10, 2010 (gmt 0)

10+ Year Member



Ah! Thanks so much - that completely did the trick. I didn't realize the "$" was an end-anchor and made rules exact match.

Sorry about the mysite - I will use a dead domain in the future.

Anyhow, thanks so much again for the assistance.

g1smd

7:09 pm on Mar 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use exactly example.com or www.example.com here. The forum software is programmed to NOT link that domain. :)