Welcome to WebmasterWorld Guest from 54.221.28.179

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewrite directory path when old directory still in URL

     

abbeyvet

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

WebmasterWorld Senior Member 10+ Year Member



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?

phranque

7:04 pm on Oct 14, 2013 (gmt 0)

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



use a regular expression that precisely matches that pattern.

what have you tried?

lucy24

9:49 pm on Oct 14, 2013 (gmt 0)

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



You need a RewriteCond to exclude requests that have already been rewritten. What does your existing rule look like?

JD_Toims

12:20 am on Oct 15, 2013 (gmt 0)

WebmasterWorld Senior Member Top Contributors Of The Month



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?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month