...

View Full Version : mod_rewrite woes



fl00d
11-21-2007, 02: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.

.htaccess


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

deny from 210.49.13.
deny from 211.30.246.

RewriteEngine on
RewriteRule ^test.html$ test2.html


test.html

<html>
<head><title>Test</title>
</head>
<body>
test
</body>
</html>

test2.html

<html>
<head><title>Test2</title>
</head>
<body>
test2 lalalala
</body>
</html>

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)

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


RewriteBase /projects/rewrite

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

fl00d
11-27-2007, 12: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 =/

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

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

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

fl00d
11-27-2007, 02: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?

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

fl00d
11-27-2007, 01: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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum