homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

301 Redirects Issue with Sub Pages

10+ Year Member

Msg#: 4535523 posted 7:15 pm on Jan 12, 2013 (gmt 0)


I'm having a lot of trouble getting 301 redirects to work for a site update. It's very odd. I'm hoping someone here might have the answer.

Many of the 301's work just fine. The problem is with old pages that are sub-pages of a parent. For example I might have something like this:

Redirect 301 /cars/ [mydomain.com...]
Redirect 301 /cars/ford/ [mydomain.com...]
Redirect 301 /cars/lexus/ [mydomain.com...]

It fails to redirect. I have tried removing the '/' from the first one as I thought it was treating it as a folder and affecting all the following redirects. That didn't work.

I've spent hours on this and can't seem to find an answer for the correct syntax when sub-pages are involved. The above are all individual pages and I'd like each treating separately and not to affect subsequent 301s.

BTW, this is for a WordPress site - if that makes a difference. The only other thing in the .htaccess other than the many redirects is the following:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Anyone know how to handle sub-pages?



10+ Year Member

Msg#: 4535523 posted 9:26 pm on Jan 12, 2013 (gmt 0)

I still don't know what went wrong here, but I think it may be a conflict with a WP plugin. I've done a workaround and just 301'd the incorrect redirects. Not exactly ideal, but it works.


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

Msg#: 4535523 posted 9:39 pm on Jan 12, 2013 (gmt 0)

Do not use Redirect or RedirectMatch.

Use only RewriteRule and place the new rules before the wordpress code.

Use example.com in code examples to suppress URL auto-linking.

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