Using relative urls with mod_rewrite
Environment: Apache 2 ships with Mac OS X Leopard; no big changes to the default httpd.conf file.
I am setting up some rewrites through my .htaccess, but I cannot seem to target the paths relative to the current directory.
# URL: http://localhost/~davis/rewrite/.htaccess
# File: /Users/davis/Sites/rewrite/.htaccess
RewriteRule go.php target.php
# Not working
I expect the rule to redirect users to http://localhost/~davis/rewrite/target.php
. It resolves the correct physical path, but gives 404 words that the path /Users/davis/Sites/rewrite/target.php
does not exist.
Everything works well if I give the full URL.
# URL: http://localhost/~davis/rewrite/.htaccess
# File: /Users/davis/Sites/rewrite/.htaccess
RewriteRule go.php /~davis/rewrite/target.php
# Works
Am I missing something? Anything to set up in httpd.conf?
Thank!
Edit: Relative urls work on my real Linux server. It's in my local Mac box that I'm having problems.
+2
source to share
3 answers