View Full Version : mod_rewrite woes

11-21-2007, 03:10 AM
Well, I decided to try playing with Apache's mod_rewrite feature and so far it hasn't been very fun. I haven't been able to get it to work! I edited my .htaccess file, uploaded it to the correct directory (infact I uploaded to all pertaining directories. ex: /projects/rewrite/ -> all folders have a copy placed in it) and yet it still doesn't work. What's worse is I'm only using a basic example! I'm having test.html show test2.html's content but not show test2.html in the address bar.


<Files 403.shtml>
order allow,deny
allow from all

deny from 210.49.13.
deny from 211.30.246.

RewriteEngine on
RewriteRule ^test.html$ test2.html




test2 lalalala

I've checked with my host and mod_rewrite is enabled.
The scripts reside at www.ridemtl.com/projects/rewrite/test.html | test2.html and also in the root directory.

Can anyone help?

P.S: I used this tutorial (http://www.workingwith.me.uk/articles/scripting/mod_rewrite)

11-21-2007, 08:54 AM
perhaps u should add

RewriteBase /projects/rewrite

11-21-2007, 02:20 PM
thank you very much! that's what it was missing! :D

11-27-2007, 01:23 AM
hmph I'm having more problems =/
Does anything look wrong with this line? I can't seem to get it to work!

RewriteRule ^new/([^0-9]+)/?$ template.php?id=$1 [L]

I'm trying to get it to work with the page www.ridemtl.com/new/template.php so that
/new/1/ = /new/template.php?id=1 (currently ID only has 1 value, which is 1)

Any idea's? I thought I had this down but apparently I don't =/

11-27-2007, 03:17 AM
RewriteRule ^new/([0-9]+)/?$ /new/template.php?id=$1 [L]

11-27-2007, 03:43 AM
Same problem. Page still isn't found :( Oh well, I'll give it another go tomorrow. Thanks for the help though.

11-27-2007, 03:46 AM
Whoops. You'll want to remove that circumflex.

11-27-2007, 03:48 AM
OK I'll try that variation too. Thanks :)

I've thought of another possibility. Is it possible it would take some time for the rewrite rule to "activate"? Like it would take some time for it to register with the server that there is a new rule it needs to follow?

11-27-2007, 04:08 AM
No, as soon as you upload it, it should take effect.

11-27-2007, 02:24 PM
I fixed it! :D
Turns out it didn't like using the starting name ^new. I don't know why but anyways...it's all good now.

Thanks for the help :)