Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a hosted account not linked to any domain at /~me.

In this home directory I have a .htaccess file:

Options +FollowSymlinks

RewriteEngine on

RewriteRule 123.html cgi-bin/example.php [nc]

The full path of example.php is /~me/public_html/cgi-bin/example.php. However /~me/123.html returns a 404.

Is my .htaccess not valid?


I also tried the following

RewriteRule ^~me/123\.html ~me/cgi-bin/example.php [nc]

and apache logs returned this:

File does not exist: /home/me/public_html/123.html

So the regex isn't matching for some reason.



RewriteRule (.*)123.html ~me/cgi-bin/example.php [nc]

removes the apache log error. So I have to assume the request is now getting caught by the .htaccess. But still 404ing so why would the path to the php file not be working? If I call it directly it executes.

share|improve this question

closed as off topic by ChrisF, Simon Sheehan, 8088, Synetech, BBlake Nov 30 '12 at 18:01

Questions on Super User are expected to relate to computer software or computer hardware within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

I think rewrite uses regexp in first argument, so you should escape dot(.) with backslash \ and second parameter should be absolute path. RewriteRule 123\.html /~me/cgi-bin/example.php [nc] – week Nov 30 '12 at 13:21
Thanks for the suggestion but that didn't work either. – user1561108 Nov 30 '12 at 13:38
I tried a variation and it returned an error in the logs, see my update above. – user1561108 Nov 30 '12 at 13:45
Than make sure that server has AllowOverride (allowing use of .htaccess) directive set and module mod_rewrite enabled. – week Nov 30 '12 at 14:03

Browse other questions tagged .