I have a set of URLs that are in the form www.website.co.uk/businessname
and these are meant to do a htaccess Proxy redirect to pull data from another domain on the server.
This is what I have:
#Start Business pages
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.outputside.org.uk/swellcottage$
RewriteRule ^(.*) http://www.datasite.co.uk/$1 [P]
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.outputsite.org.uk/hawthorn-books$
RewriteRule ^(.*) http://www.datasite.co.uk/$1 [P]
#End Business Pages
The first rule works perfectly, displaying the contents of http://www.datasite.co.uk/swellcottage
on the URL www.outputsite.org.uk/swellcottage
but the second rule/condition doesn't work.
I looked at escaping the -
character in the URL as so:
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.outputsite.org.uk/hawthorn\-books$
RewriteRule ^(.*) http://www.datasite.co.uk/$1 [P]
#End Business Pages
But this still doesn't seem to engage correctly, the rewrite rules do not work and the site replies with the fallback 404 that the page www.outputsite.org.uk/hawthorn-books
does not exist.
Where else and how else should I escape the dash or otherwise what's wrong with my syntax here? cheers
ps. I have it that filenames (index.php) and folder names (/places/) are not subject to the proxy redirects .
UPDATE
I have more Rules in my htaccess:
#to add www. to each request.
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301]
#Start biz pages
...
#End biz Pages
#to prevent error looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
I have also run the same code above with hawthornbooks
without the dash, escaped or otherwise and the code works correctly, so I need to find out the correct way of escaping the dash character. All code and work is UTF-8.
NOTE: This issue appears similar to Why if I put a "-" dash in a rule in my htaccess doesn't work? but I found no solution to that problem.
This is intended to be a temporary rather than a permanent solution, but you might try the following rule:
This will look for any URI which conforms to the pattern
www.outputsite.org.uk/hawthorn
followed by any number of characters (or zero characters) which aren't/
and then ending with an (optional)/
.If problem is just a hyphen this should work: