views:

46

answers:

3

I have this in my .htaccess file...

RewriteEngine on
RewriteRule ^/invite$ /invite.html

It's meant to let a user access this url:

http://mysite.com/invite

and display the invite.html page. I don't want to redirect the user, but just show them the invite.html page from a better looking URL.

When I browse to http://mysite.com/invite though, I get a 404 not found error.

Is there anything I'm doing wrong? I've tried looking at tutorials for using mod_rewrite but I seem to be doing what they're telling me too...

Thanks!

A: 

Did you make sure that AllowOverride All is set for the directory where the .htaccess file lies? Else the file might be ignored.

If this isn't the case, you should check out Apache's log files for more hints (/var/log/apache on Linux).

AndiDog
I'm on shared hosting so I don't think I can view the Apache logs, and I can't see my own account specific logs anywhere either.
VIVA LA NWO
Ah! I found my logs in cPanel, I have loads of lines reading: `File does not exist: /home/myuser/public_html/invite`. Which doesn't make sense to me, from what I know `/invite` doesn't need to exist as it's what I'm trying to make...
VIVA LA NWO
A: 

You're missing a RewriteCond directive. That's the one that does the actual testing Condition to match a URL. The RewriteRule is invoked only when one or more RewriteConds are matched.

Marc B
I don't think that's accurate, you can have `RewriteRule` without `RewriteCond`
Michael Mrozek
+2  A: 

I don't think there should be a / in that RewriteRule:

RewriteEngine on
RewriteRule ^invite$ invite.html
Trey
Ah perfect, works now :) Thanks a lot!
VIVA LA NWO