Forum Moderators: phranque

Message Too Old, No Replies

On adding RewriteCond RewriteRule doesnt work

         

anjanesh

2:35 pm on Sep 10, 2005 (gmt 0)

10+ Year Member



Here, http://localhost/mysite/somepage.html works:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteRule (.*)\.html$ index.php?a=$1

but after I added the folder in the RewriteRule, it doesnt work :

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteRule ^/mysite/(.*)\.html$ index.php?a=$1

Any idea how why?
Thanks

jd01

9:47 am on Sep 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi anjanesh,

You have your /'s reversed for .htaccess use:
RewriteRule ^/mysite/(.*)\.html$ index.php?a=$1 [NC]

Should be:
RewriteRule ^mysite/(.*)\.html$ /index.php?a=$1 [NC]

And more efficient and correct would be:
RewriteRule ^mysite/([^.]+)\.html$ /index.php?a=$1 [NC,L]

[L] = Last -- should always be used unless you know you do not need it.
([^.]+) = Forward looking (anything that is not a .(dot)) -- it is faster to check for a single character and break when you find it, than to get everything and backtrack.

Justin