Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewrite directory path when old directory still in URL

     
4:48 pm on Oct 14, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 29, 2003
posts:944
votes: 0


Don't know if the title is clear, but basically I'm a bit afraid of causing some sort of redirect loop, so wanted to get a bit of advice.

Essentially, I've changed the location of a WP install

Old URL:
http://www.somesite.com/blog/


New URL
http://www.somesite.com/newname/


However, the slug for the blog page on the new install is 'blog'

So, its url is:
http://www.somesite.com/newname/blog/


Which makes me apprehensive just redirecting /blog/ to /newname/
as it'll probably end up going around in circles.

At a push, I could alter the slug, but would rather not. How to rewrite?
7:04 pm on Oct 14, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10543
votes: 8


use a regular expression that precisely matches that pattern.

what have you tried?
9:49 pm on Oct 14, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12709
votes: 244


You need a RewriteCond to exclude requests that have already been rewritten. What does your existing rule look like?
12:20 am on Oct 15, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:July 19, 2013
posts:1097
votes: 0


You should be fine as long as you start-anchor the blog [RewriteRule ^blog/] and make sure you're redirecting external requests, but ignoring internal requests if they're using the same path via a RewriteCond with %{THE_REQUEST}

The use of a condition and the_request actually depend on the exact situation you're dealing with, so they may be unnecessary, but the only way to know for sure is to have the specifics, which means, as phranque and Lucy24 are asking, I have to ask: what do your existing rules look like and what have you already tried?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members