Page 1 of 1

Custom URL rewrite problem

Posted: Tue Apr 12, 2011 2:26 pm
by asdf
I hope this is acceptable for this forum as this may be more Apache related question than CMSMS problem.

I have a UDT for say products (nothing to do with Products module, just easy to understand example) that can be called with or without GET parameter. So it can be accessed as http://site/cmsms/test/products and http://site/cmsms/test/products?id=123. Now I would like to make URLs with parameters prettier and possibly more SEF, something like http://site/cmsms/test/products/title/123 where title does nothing but looks pretty.

I have expanded the standard rules with one line, the first RewriteRule below.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cmsms/test

RewriteRule ^produ/([a-z]+)/([0-9]+)$ products?id=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
This works well, but now URLs are inconsistent, the "sub-front" is at http://site/cmsms/test/products while data pages are http://site/cmsms/test/produ/title/123. But if I change produ to products it stops working with 404 error from Apache, the front opens still.

I have tried different RewriteCond to run the above rule only if there's parameters but have not been able to get it work.

I'm running 1.9.4.1 on Ubuntu Server 10.04. With mod_rewrite enabled in the config.php, obviously :)

Any advice is appreciated!