Forum Moderators: phranque

Message Too Old, No Replies

Getting mod_rewrite to work!

Placed code into htaccess file, but no joy!

         

woldie

5:26 pm on Mar 1, 2004 (gmt 0)

10+ Year Member



Hi,

I've been trying to get mod_rewrite to work on my server, not having much luck.

What I've done is placed the code into an .htaccess file placed into the 'test' directory, and also placed the file in the root directory.

This is what I'm trying to achieve:-

[mydomain.com...]

and I would like this to show the following URL:

[mydomain.com...]

Code:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/test/index.php$ [NC]
RewriteCond %{QUERY_STRING} sid=([0-9]+) [NC]
RewriteRule ^/TEST/index.php /test/%1.html [L,R]

Then I refresh the website and nothing seems to be working.

I've checked to see mod_rewrite is installed, by running this command

/etc/httpd/bin/httpd -l

and I have mod_rewrite. I've restarted the web server, and still doesn't work.

Any ideas?

Many Thanks ;)

gethan

5:45 pm on Mar 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try:

RewriteEngine On
RewriteRule ^/test/(.*)\.html /test/index.php?sid=$1 [L,R]

Your rule as it stands is redirecting any request for /TEST/index.php to /test/%1.html - which errors as it dosent exist. (plus % is a bad character)

So there are lots of errors and the basic logic is backwards.

HTH

jdMorgan

6:40 pm on Mar 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"%1" is not a bad character sequence: It is used to back-referenced the first matched parenthesized sub-pattern in the last preceding RewriteCond which matched, in this case, "([0-9]+)".

Jim