htaccess rewrite issue

#1
Hi,

I recently moved an OpenCart from Apache server to LiteSpeed.

Some rewrite rules are not working anymore:

RewriteRule ^([^?]*)$ index.php?_route_=$1 [QSA]
RewriteRule ^([^?]*)/promo index.php?_route_=$1&filter=promo [QSA]

I also need to work query like "category/product" on first rule.

Thank you.
 

mistwang

LiteSpeed Staff
#3
First thing, make sure you have "RewriteEngine on" in the .htaccess, assuming the rules is in .htaccess.

Please turn on rewrite logging by adding "RewriteLogLevel 9" to the Apache vhost configuration if LiteSpeed read Apache configuration. Then check error log for rewrite related log entries.
 
#4
RewriteEngine is on.

It is working somehow, but the $_SERVER['QUERY_STRING'] returns _route_=cars/ford/promo instead _route_=cars/ford&filter=promo like before.

I don't have permissions to add RewriteLogLevel.


 

Pong

Administrator
Staff member
#5
Try to change the sequence and add "L " to it and see how it's going:

RewriteRule ^([^?]*)/promo index.php?_route_=$1&filter=promo [L, QSA]
RewriteRule ^([^?]*)$ index.php?_route_=$1 [L,QSA]
 
#6
No success.

Bellow is my htaccess:

RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)

RewriteRule ^([^?]*) index.php?_route_=$1 [QSA]
RewriteRule ^([^?]*)/page([0-9]+) index.php?_route_=$1&page=$2 [QSA]
RewriteRule ^([^?]*)/promo index.php?_route_=$1&filter=promo [QSA]


Now $_SERVER['QUERY_STRING'] returns _route_=cars/ford/promo instead_route_=cars/ford&filter=promo

Any other sugestions?
 

NiteWave

Administrator
#9
not sure if following change will work(re-order only):

RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

RewriteBase /

RewriteRule ^([^?]*)/page([0-9]+) index.php?_route_=$1&page=$2 [QSA,L]
RewriteRule ^([^?]*)/promo index.php?_route_=$1&filter=promo [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)

RewriteRule ^([^?]*) index.php?_route_=$1 [QSA,L]
 
Top