htaccess的打破了(转义)冲刺的重定向URL [英] htaccess breaks with (an escaped) dash in the redirect URL
问题描述
我有一组网址是形式www.website.co.uk/businessname
I have a set of URLs that are in the form www.website.co.uk/businessname
和这些是为了做一个htaccess的代理重定向到从服务器上的其他域提取数据。
and these are meant to do a htaccess Proxy redirect to pull data from another domain on the server.
这是我有:
#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
第一条规则完美的作品,在网址 WWW显示
,但第二条规则/条件不起作用。 http://www.datasite.co.uk/swellcottage
的内容。 outputsite.org.uk/swellcottage
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.
我看着逃避 -
字符的URL像这样:
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
但是,这似乎仍然不能正确地搞,重写规则不工作,并现场回答与回退404页 www.outputsite.org.uk/hawthorn-books
不存在。
在别的地方,我应该怎么回事逃脱破折号或其他什么地方错了我在这里的语法?欢呼声
Where else and how else should I escape the dash or otherwise what's wrong with my syntax here? cheers
PS。我有它的文件名(的index.php)和文件夹的名称(/地点/)不受代理重定向。
ps. I have it that filenames (index.php) and folder names (/places/) are not subject to the proxy redirects .
我在我的htaccess更多的规则:
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]
我也运行在同一code以上与 hawthornbooks
无破折号,躲过或以其他方式和code正常工作,所以我需要找到出逃避连字符的正确方法。所有code和工作是UTF-8。
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.
注:此问题出现类似于<一href="http://stackoverflow.com/questions/14379842/why-if-i-put-a-dash-in-a-rule-in-my-htaccess-doesnt-work">Why如果我把一个&QUOT; - &QUOT;破折号在我的htaccess的规则不起作用?但是我发现没有办法解决这个问题。
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.
推荐答案
如果问题仅仅是一个连字符,这应该工作:
If problem is just a hyphen this should work:
#Start Business pages
RewriteCond %{HTTP_HOST} ^(www\.)?outputside\.org\.uk$ [NC]
RewriteRule ^(swellcottage)/?$ http://www.datasite.co.uk/$1 [P,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?outputside\.org\.uk$ [NC]
RewriteRule ^(hawthorn.books)/?$ http://www.datasite.co.uk/$1 [P,NC]
#End Business Pages
这篇关于htaccess的打破了(转义)冲刺的重定向URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!