0

I've just moved from a Litespeed hosting to an Apache's one. However such redirects stopped working.

RewriteCond %{HTTP_HOST} ^nix.foo.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nix.foo.com$
RewriteRule ^(.*)$ "http\:\/\/www\.foo\.com\/nix\.php" [R=301,L]

On Firefox, I get a "failed to connect to the server" message. I tried simpler mod_rewrite redirects such as

RewriteRule ^foo.php$ bar.php

and they work, so mod_rewrite seems to be already enabled thanks to RewriteEngine on.

Any hints? Thanks

edit: It seems that all I had to do was creating an empty "nix" folder, and the redirect worked.

4

2 回答 2

0

似乎我所要做的就是创建一个空的“nix”文件夹,并且重定向工作。

于 2013-09-15T14:26:24.233 回答
0

我看到你的问题已经解决了,但这里有几点需要注意。

您需要在RewriteCondnot in 中进行转义,RewriteRule或者.在其位置接受任何字符,例如nixxfoo.com. 您还可以将您的两个HTTP_HOST条件合二为一,并且无需捕获 URL,(.*)因为在替换过程中不会引用它。

RewriteCond %{HTTP_HOST} ^(www\.)?nix\.foo\.com$ [NC]
RewriteRule ^ http://www.foo.com/nix.php [R=301,L]
于 2013-09-15T15:22:35.993 回答