homepage Welcome to WebmasterWorld Guest from 54.161.220.160
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

    
301 Redirect help - Trying to redirect a few pages to specific destinations
kmac31



 
Msg#: 4593734 posted 12:15 am on Jul 17, 2013 (gmt 0)

Basically I am trying to redirect a few pages from an old site to specific urls at a new site.

All other URLs on that old site should be redirected to a specific subdirectory on the new site.

This is how I'm trying to do it, but everything is being sent to http://www.example.com/everything-else-points-here/


RewriteRule ^/index.php/exception1(.*)$ http://www.example.com/destination1 [R=301,L]
RewriteRule ^/index.php/exception2(.*)$ http://www.example.com/destination2 [R=301,L]
RewriteRule ^/index.php/exception3(.*)$ http://www.example.com/destination3 [R=301,L]

RewriteRule ^(.*)$ http://www.example.com/everything-else-points-here/ [R=301,L]



Any help would be appreciated because I seem to have hit a wall at this point. Thanks!

Edit: Nevermind, I didn't escape the . in index.php... sigh

 

lucy24

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



 
Msg#: 4593734 posted 3:18 am on Jul 17, 2013 (gmt 0)

But the unescaped . is just for insurance. In this context it would only make a difference if you're asking for a file named indexzphp/blahblah and getting redirected against your will.

The leading directory slash, otoh, would be a big problem if you're doing this in htaccess or any <directory> section.

phranque

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



 
Msg#: 4593734 posted 4:29 am on Jul 17, 2013 (gmt 0)

welcome to WebmasterWorld, kmac31!


you should also avoid redirecting a large number of urls to a single url as it's rarely a good experience for the visitor and google is likely to treat this as a soft 404 or might even penalize you for using techniques that manipulate pagerank.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4593734 posted 12:57 pm on Jul 17, 2013 (gmt 0)

Redirecting (.*) to a single URL means that requests for robots.txt, images, css, javascript and other such files are also redirected.

Change the "greedy, promiscuous and ambiguous" .* pattern to something that more closely matches requests for only pages.

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