PDA

View Full Version : mod_rewrite freaks - I need your help!



screamfine
05 Oct 2005, 04:34 AM
Hi!

I have an URL like this:

http://www.mydomain.com/index.php?_id=just-a-test

I want to rewrite this into the following:

http://www.mydomain.com/just-a-test.html

My .htaccess file looks like this:



php_flag allow_call_time_pass_reference on
RewriteEngine On
RewriteBase /
RewriteRule ^([^-]+)-(.+)\.html$ index.php?_id=$1&_news=$2 [L]
RewriteRule ^(.+)\.html$ index.php?_id=$1 [L]


The problem is:

http://www.mydomain.com/index.php?_id=just-a-test
becomes:
http://www.mydomain.com/das.html ("a-test" is missing...)

All hyphens and parameters get lost ... what am I doing wrong? :roll:

I'm looking forward to your replies! :private:

Thank You very much!

P.S. My Apache version is: Apache/2.0.50 (Linux/SUSE).

rsymonds
05 Oct 2005, 01:24 PM
Try something like this:



php_flag allow_call_time_pass_reference on
RewriteEngine On
RewriteRule ^(.+)\.html$ index.php?_id=$1 [QSA,L]


This will also pass any other query string information so that if you had a URL like:



http://www.mydomain.com/just-a-test.html?FirstName=Bill


The query string information would be passed.