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

    
[R=301,L] not working
Jesse_Smith

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 6468 posted 1:54 am on Jun 28, 2006 (gmt 0)

Is there any way to make this code work? I think special characters are keeping it from redirecting.

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^showthread\.php\?t\=10285\&page\=([^.]+)$ http ://www.DOMAIN.com/showthread.php?t=14913 [R=301,L]
RewriteRule ^showthread\.php\?t\=10285$ http ://www.DOMAIN.com/showthread.php?t=14913 [R=301,L]

 

jdMorgan

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



 
Msg#: 6468 posted 3:19 am on Jun 28, 2006 (gmt 0)

No, the problem is that RewriteRule can't 'see' query strings.

Use something like

RewriteCond %{QUERY_STRING} ^page=foo&destintation=bar$

to test and manipulate query strings.

Search WebmasterWorld for 'rewriterule rewritecond query_string' for lots more threads on this subject.

Jim

Jesse_Smith

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 6468 posted 11:01 am on Jun 28, 2006 (gmt 0)

RewriteCond %{QUERY_STRING} ^t=10285$
RewriteRule ^([^.]+)$ http ://www.DOMAIN.com/showthread.php?t=14913 [R=301,L]

RewriteCond %{QUERY_STRING} ^t=10285&page=([^.]+)$
RewriteRule ^([^.]+)$ http ://www.DOMAIN.com/showthread.php?t=14913 [R=301,L]

isn't working. The change is just changing 10285 to 14913 and URL's with &page= to go to the 14913 url with out &page=.

showthread.php?t=14913

The script URL is the same at both URLs.

jdMorgan

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



 
Msg#: 6468 posted 2:31 pm on Jun 28, 2006 (gmt 0)

The two rules should be reversed, but you only need one anyway:

RewriteCond %{QUERY_STRING} ^t=10285(&page=[^&]+)?$
RewriteRule ^showthread\.php$ http://www.example.com/showthread.php?t=14913%1 [R=301,L]

Jim

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