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

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

Apache Web Server Forum

    
Need Help with redirecting print url
alika




msg:4599233
 12:36 pm on Aug 4, 2013 (gmt 0)

I removed a print plugin and now the URLs are coming as 404. I need to redirect them to the correct URL

My old URLs were

www.URL.com/blog/year/month/post-title/print

I want to redirect them to their equivalent

www.URL.com/blog/year/month/post-title/

This is the htaccess I created, but it is not working. I put it in the root folder on top of everything else (not many) in the .htaccess, but no success

Am I missing something?

RewriteEngine on
RewriteRule ^(.*)/print/$ /$1 [R=301,NC,L]

 

phranque




msg:4599436
 11:31 am on Aug 5, 2013 (gmt 0)

that trailing slash in the Pattern won't match the request and for a redirect the Substitution string should be fully qualified with the canonical protocol and hostname.

also, since paths and filenames are case-sensitive on most servers, would also recommend against using the [NC] flag.

g1smd




msg:4599460
 12:47 pm on Aug 5, 2013 (gmt 0)

The pattern does not match the example URL.
Look at the trailing slash.

alika




msg:4599486
 2:54 pm on Aug 5, 2013 (gmt 0)

Should it be

RewriteEngine on
RewriteRule ^(.*)/print /$1 [R=301,L]

g1smd




msg:4599557
 7:38 pm on Aug 5, 2013 (gmt 0)

With that code, the target URL will be missing the trailing slash.


Try this:
RewriteRule ^([^/]+/)print$ http://www.example.com/$1 [R=301,L]
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