Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_HOST} ^externaldomain\.com$
That works fine, I have tried all sorts of variants on the rule. If I do this:
RewriteRule ^(.*)$ folder/$1 [R=301,L]
it displays the homepage of homedomain while keeping externaldomain in the url, but it isn't redirecting to the folder I want it to. If I do this:
RewriteRule ^(.*)$ /folder/$1 [R=301,L]
it redirects to the proper folder but the url changes from externaldomain to homedomain. I have looked all over this site but can't seem to figure this one out. I have tried google but one issue is I don't know exactly what to look for or what the proper term for what I am doing is. Any help is most appreciated. Thanks.
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?externaldomain\.com\.?(:[0-9]+)?$
RewriteCond $1 !^folder/
RewriteRule ^(.*)$ /folder/$1 [L]
The second RewriteCond prevents recursively rewriting a request for "/x" to /folder/x to /folder/folder/x to /folder/folder/folder/x, etc.
The RewriteRule syntax is modified to specify an internal rewrite.
Jim
The requested URL /folder/ was not found on this server.
The folder is definitely on the server so it just can't find it. So what I did next was try to use an absolute path in the rewrite rule and changed it to something like this:
RewriteRule ^(.*)$ /var/www/html/folder/$1 [L]
and when I do that I get this error:
The server encountered an internal error or misconfiguration and was unable to complete your request.
Just for testing purposes I have /var/www/folder and /var/www/html/folder both set up and it's not finding either one. The .htaccess file is in the /var/www/html/ directory. I'll keep looking around the web, any help you can provide is most appreciated.
Also, I have presumed that your code is in example.com/.htaccess. If it is in a server config file or in a different location, please let us know, as this makes a big difference.
Jim