Forum Moderators: phranque

Message Too Old, No Replies

ReWrite script from apache 1.3 to 2.2

         

jonnyd91

4:01 pm on Apr 15, 2011 (gmt 0)

10+ Year Member



Hi, I had been using the following script for friendly urls and it is working fin in apache 1.3. We just upgraded to apache 2.2.17 and it doesnt seem to be working anymore.

Is there something that needs to be tweaked to work in 2.2?


http://www.mysite.com/products?BRAND=ADIDAS&VENDORCODE=581 (ORIGINAL URL)

http://www.mysite.com/products/ADIDAS/581 (FRIENDLY URL)

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*/)?products/([^/]+)/([0-9]+)/?$ $1/products?BRAND=$2&VENDORCODE=$3 [PT,L]
RewriteRule ^(.*/)?products/([^/]+)/([^/]+)/([0-9]+)/?$ $1/products?BRAND=$2&VENDORCODE=$3&offset=$4 [PT,L]

RewriteRule ^(.*/)?DeptItems/([^/]+)/([0-9]+)/?$ $1/DeptItems?BRAND=$2&catCode=$3 [PT,L]
RewriteRule ^(.*/)?DeptItems/([^/]+)/([^/]+)/([0-9]+)/?$ $1/DeptItems?BRAND=$2&catCode=$3&offset=$4 [PT,L]

RewriteRule ^(.*/)?itemdetail/([^/]+)/([^/]+)/?$ $1/itemdetail?BRAND=$2&desc1=$3 [PT,L]

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(login|myaccount|register|updateUser|accountedit|confirm|Submit|ReviewOrder|ExpressOrder|DispExpOrder|DispExpInvoice|ShowInfoExp|DispOrderInfoExp|OrderExp)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#RewriteCond %{SERVER_PORT} !^80$
#RewriteRule ^(displayCart)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^$ http://%{HTTP_HOST}/ [R=301,L]

g1smd

4:14 pm on Apr 15, 2011 (gmt 0)

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



(.*/)? should be ([^/]+/)*

Where the target begins $1/ add a leading slash /$1/

(login|myaccount|register|updateUser|accountedit|confirm|Submit|ReviewOrder|ExpressOrder|DispExpOrder|DispExpInvoice|ShowInfoExp|DispOrderInfoExp|OrderExp)

simplifies to

(login|myaccount|register|updateUser|accountedit|confirm|Submit|(Review|Express)Order|DispExp(Order|Invoice)|(Show|DispOrder)InfoExp|OrderExp)

jonnyd91

4:53 pm on Apr 15, 2011 (gmt 0)

10+ Year Member



ok id changed it to this:

RewriteRule ^([^/]+/)*products/([^/]+)/([0-9]+)/?$ /$1/products?BRAND=$2&VENDORCODE=$3 [PT,L]


I dont know if it matters but i am using apache in front of tomcat and passing the requests from apache to tomcat.

I still get a 404 error with that rule. I had the server company recompile apache to version 1.3 and it works with my old rules, however when i upgrade to 2.2.17 theu do not work anymore.

g1smd

5:06 pm on Apr 15, 2011 (gmt 0)

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



I have corrected obvious syntax errors, but cannot advise on the actual URLs and paths as only you and your hosting company could know what they are.

There are further problems with your rules. The most obvious is that they are likely in the wrong order. The redirects should be listed fist, not last. They should be ordered from most selective to most general.

jonnyd91

5:13 pm on Apr 15, 2011 (gmt 0)

10+ Year Member



hmm so how would you order the rules i currently have

thanks
John