John John - 1 year ago 88
Apache Configuration Question

Apache localhost double www.domain (not host) directory rewrite

I have to provide public access in certain circumstances to a client domain from the main business domain. I'm working to get this to work locally first (

) and therefore only need help with the local system's rewrite rule please. These domains are not the host (host is
) though I test all manners of access (192., 127., etc).

Requested URL


File Server Path


.local.htaccess Location


The general code I've been tinkering with:

RewriteEngine on
RewriteRule ^[.*/].*/(www.)+/images/(.*)$ $1/images/$2

I've had success with the scripts directory (all rules, though not the images directory) using the following (the images directory even with an otherwise empty

RewriteEngine on
RewriteRule ^[^/].*/scripts(.+) scripts$1

Answer Source

Try this rule as your very first rule in your .local.htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(Version-1\.0)/www[^/]*/(www[^/]*/\S*)\s
RewriteRule ^ /%1/%2 [L,NE,R=301]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download