Page 1 of 1

[SOLVED] Advanced mod_rewrite usage

Posted: Sat Nov 29, 2008 3:40 pm
by vincentvega
Hi all,

Since a short time I'm using CMS Made Simple (and I really love it), but unfortunately I came across a problem while using mod_rewrite.

I wrote a 'special' page called news-item which will fetch a remote news-item from an XML feed. To use it I pass ?news_id=23 to it so the script knows which news article to fetch. This is all working great, but now I want to use SEO friendly URLs (I already use it for the 'normal' pages).

What I want is to translate http://www.mysite.com/news-item/23/This is the title/ to http://www.mysite.com/index.php?page=ne ... news_id=23

So I altered the .htaccess file to look like this:

RewriteRule ^news-item/(.+)/(.+)$ index.php?page=news-item&news_id=$1&news_title=$2 [QSA]
RewriteRule ^news-item/(.+)/$ index.php?page=news-item&news_id=$1 [QSA]
RewriteRule ^news-item/(.+)$ index.php?page=news-item&news_id=$1 [QSA]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

However, this breaks the other pages (especially http://www.mysite.com/ which returns a 404).

Does anyone know how to fix this?

Thanks in advance for your time!

Yours Sincerely,
Vincent

Re: Advanced mod_rewrite usage

Posted: Wed Dec 03, 2008 4:00 pm
by vincentvega
Fixed. I had to add rewrite conditions to all of the lines.