Forum Moderators: phranque

Message Too Old, No Replies

Problem with RewriteRule and 404 not found

         

asantos

5:10 am on Apr 4, 2008 (gmt 0)

10+ Year Member



Hi, this is my .htaccess:

RewriteEngine on
RewriteRule ^activation/?$ /activation.php [NC,L]

When opening example.com/activation it renders the page OK, but when trying to access example.com/activation?msg=1 or any other querystring the browser throws a 404 - Not Found message.

Im kind of desperate. Why does it throw an error? Thanks.

[edited by: jdMorgan at 1:24 pm (utc) on April 4, 2008]
[edit reason] example.com [/edit]

Samizdata

7:36 am on Apr 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why does it throw an error?

Because you haven't told it not to?

If I understand what you are trying to do (and I admit that I might not) then...

RewriteRule ^test test.php [NC,L]

might be enough to do what you want - if you don't have other files starting with "test"..

jdMorgan

1:25 pm on Apr 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's nothing wrong with the original code, assuming that mod_rewrite is working and that you've put the code into example.com/.htaccess.

By default, mod_rewrite passes a query string without modification unless you explicitly change the query string. So, if you've got mod_rewrite working at all, then your code should work.

An issue that comes up all the time is this: Did you completely flush your browser cache before testing? You've got to do this after any code change, in order to avoid seeing stale results cached by your browser. This may in fact be by "example.com/activation" works, and the other URLs don't.

Or, it's possible that your script is throwing the error.

In these cases, it's often useful to take a step back and try a dirt-simple rule:


RewriteRule ^foo\.html$ http://www.google.com/ [R=302,L]

If you request foo.html from your server, you should land at google.

Jim

asantos

4:25 am on Apr 5, 2008 (gmt 0)

10+ Year Member



hi guys,
i fixed the problem. my website is on a VPS, and the server type was lighttpd, i changed it to apache and voila!