Help with rewrite

#1
Hello!

First of all, sorry for my english.

I have a major problem that I can't solve for about two days already...
I can't properly write rewrite rule.

What I want to do? I need my web site to ignore number of string in url. For example, I have link:
www.site.com
www.site.com/category/
www.site.com/category/product/

And I have a list with strings (geo1, geo2, geo3, ... , geoN) that I iwll have to insert into URL, BUT they need to be ignored by server WITHOUT changing URL.
www.site.com/geo1/ should open www.site.com (but with geo1 in URL)
www.site.com/geo1/category/ shoul open www.site.com/category (saving geo1 in URL)

My default htaccess rules for CMS (opencart) - looks like this
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
What I did? I write new additional rule
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^/(geo1|geo2|geo3|geo4|geo5)([^?]*)$ /index.php?_route_=$2 [L]
So all .htaccess looks like this:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^/(geo1|geo2|geo3|geo4|geo5)([^?]*)$ /index.php?_route_=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
It works like a charm with Apache in my local machine, but it fails with Litespeed. LS DOES show correct page with site.com/geo1/category - it shows me category page, BUT it changes my URL, so it looks like site.com/category.

At litespeed config panel in rewrite section i have this lines
Code:
rewrite  {
  enable                  1
  rules                   <<<END_rules
rewriteFile          /var/www/site/.htaccess
/var/www/site/.htaccess - contains the code above.

So, please, can you tell me, is there are any way to tell litespeed NOT TO CHANGE URL ?

Thanks in advance!
 
Last edited by a moderator:

Pong

Well-Known Member
Staff member
#2
rewrite rule will redirect the URL to new one. it is the same with apache and LiteSpeed.

Instead of setup redirect, maybe you just create a copy of files from /category/ to /geo1/category/ or some simbolic links.
 
Last edited by a moderator:
Top