I have a rewrite rule in my .htaccess.
RewriteRule ^(.+?)$ /user_home.php?domain=$1 [L,QSA]
Which redirects mysite.com/mypage
to mysite.com/user_home.php?domain=mypage
This works fine on my shared host, but when working locally, my site is located in www/mysite/
and instead of redirecting to www/mysite/user_home.php?domain=mypage
it tries to redirect to www/user_home.php?domain=mypage
which doesn't exist.
I get the following error in my Apache Logs
[error] [client ::1] script 'C:/wamp/www/user_home.php' not found or unable to stat
How can I alter my .htaccess to make it direct to the file in the current directory using a relative path instead of an absolute path..
You just need to remove leading slash from the target URL in your rule like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ user_home.php?domain=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
is also needed to prevent infinite looping.