Forum Moderators: phranque

Message Too Old, No Replies

A little permanent redirection issue.

         

youngbobby

9:00 pm on Jan 3, 2011 (gmt 0)

10+ Year Member



Hi everybody,

I am having a little permanent URL redirection issue here. The 1st code below works fine but I'm having issues with the second. A little assistance will be appreciated. Thanks :)


This one was successful:

RewriteRule ^Categories/([0-9]+/[0-9]+/[A-Za-z0-9-]+)/$ http://SITEURL/Categories/$1 [R=301,L]

RewriteRule ^Categories/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+)?$ /Site/categoryView.php?page=$1&id=$2&catname=$3 [L]



This is where my main issue lies.

RewriteRule ^Directory([0-9]+).php?$ http://SITEURL/Site/Directory$1.php [R=301,L]

RewriteRule ^Directory([0-9]+).php?$ /Site/Directory.php?page=$1 [L]


I don't know what I'm not doing right? :-/

g1smd

11:24 pm on Jan 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The Redirect should have a preceding RewriteCond testing THE_REQUEST so that the redirect is invoked only for direct client requests.

There's several thousand prior threads with example code, as this is a question that comes up every few days. It's not too obvious how to prevent the infinite loop that otherwise occurs.

youngbobby

2:21 am on Jan 4, 2011 (gmt 0)

10+ Year Member



OK, I've done that..

Just in case this is what i used.

RewriteCond %{QUERY_STRING} ^page=([0-9]+)?$
RewriteRule ^Directory([0-9]+).php?$ http://SITEURL/Site/Directory$1.php [R=301,L]

RewriteRule ^Directory([0-9]+).php?$ /Site/Directory.php?page=$1 [L]


Not too good with mod_rewrite so if i'm wrong, don't hesitate to tell me that i am. :)

g1smd

11:19 pm on Jan 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have tested QUERY_STRING which can be altered by rewrites.

You need to test THE_REQUEST to see what the browser actually asked for.

jdMorgan

7:50 pm on Jan 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We need to back off here and establish a few basic points first:

  • What is the overall purpose of these rules? In terms of requested URLs and server filepaths, what are you trying to accomplish?
  • What is the specific problem? What did you expect to happen, and how did your test results differ from what you expected?
  • How did you test to reveal that problem? -- For example, what URLs are you testing with?

    Jim
  •