homepage Welcome to WebmasterWorld Guest from 54.166.53.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Rewrite directory path when old directory still in URL
abbeyvet

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4616664 posted 4:48 pm on Oct 14, 2013 (gmt 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?

 

phranque

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



 
Msg#: 4616664 posted 7:04 pm on Oct 14, 2013 (gmt 0)

use a regular expression that precisely matches that pattern.

what have you tried?

lucy24

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



 
Msg#: 4616664 posted 9:49 pm on Oct 14, 2013 (gmt 0)

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

JD_Toims

WebmasterWorld Senior Member Top Contributors Of The Month



 
Msg#: 4616664 posted 12:20 am on Oct 15, 2013 (gmt 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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved