Welcome to WebmasterWorld Guest from 54.158.81.119

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Need Help with redirecting print url

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

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 27, 2003
posts:1597
votes: 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]
11:31 am on Aug 5, 2013 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10589
votes: 21


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.
12:47 pm on Aug 5, 2013 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


The pattern does not match the example URL.
Look at the trailing slash.
2:54 pm on Aug 5, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 27, 2003
posts:1597
votes: 0


Should it be

RewriteEngine on
RewriteRule ^(.*)/print /$1 [R=301,L]
7:38 pm on Aug 5, 2013 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 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]