-1

我有点删除了我的 .htacess 上的一行

现在我无法打开 support.sitename.com

这是我的支持文件夹, public_html/support

但我怎样才能将其重定向到support.sitename.com

我写了这个,

 #RewriteCond %{REQUEST_URI} != support.sitename.com$

我很确定那不是我删除的代码。但它比那更接近。我遇到了大麻烦,请帮助>.<

RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|gif|json|js)
RewriteCond %{REQUEST_URI} !^/support$
RewriteCond %{REQUEST_URI} !^/PHPMailer$
RewriteCond %{REQUEST_URI} !^/scripts$
RewriteCond %{REQUEST_URI} !/adarna.html$
RewriteCond %{REQUEST_URI} !/bh6750.html$
RewriteCond %{REQUEST_URI} !/contact-us.html$
RewriteCond %{REQUEST_URI} !/dr-holmes.html$
RewriteCond %{REQUEST_URI} !/email.php$
RewriteCond %{REQUEST_URI} !/jo-rubio.html$
RewriteCond %{REQUEST_URI} !/npk-medical.html$
RewriteCond %{REQUEST_URI} !/oraderm.html$
RewriteCond %{REQUEST_URI} !/outsource-to-philippines.html$
RewriteCond %{REQUEST_URI} !/rw-chinese.html$
RewriteCond %{REQUEST_URI} !/rw-manila.html$
>> area of code i deleted
RewriteRule (.*) / [R=301,L]
4

3 回答 3

1
# it could be
RewriteCond %{HTTP_HOST} !^support\.sitename\.com$
# or this
RewriteCond %{HTTP_HOST} !^(www\.)?support\.sitename\.com$

# or even this
RewriteCond %{HTTP_HOST} ^support\.sitename\.com$
# or this
RewriteCond %{HTTP_HOST} ^(www\.)?support\.sitename\.com$

取决于您要对代码执行什么操作以及代码上的文件名所在的位置,您未提及的位置。

要将/support/support/重定向到support.sitename.com,您最好在.htaccess文件中使用这些条件和规则:

RewriteCond %{HTTP_HOST} !^(www\.)?support\.sitename\.com$
RewriteRule ^support/?$ http://support.sitename.com/
于 2013-04-11T04:44:42.323 回答
0

试试这个代码片段

RewriteEngine on
RewriteCond %{HTTP_HOST} ^m\.example\.com$
RewriteRule ^ http://example.com/m%{REQUEST_URI} [L,P]
于 2013-04-11T03:24:49.520 回答
0

我发现了这个:将 support.example.com 重定向到 example.com/support:

几个不同的例子

#Turns the rewrite engine on.
RewriteEngine on

#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

#www.domain.com and domain.com will map to the folder {root}/folder1/
RewriteCond %{HTTP:Host} ^(?:www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/folder1/
RewriteRule ^(.*) folder1/$1 [NC,L,NS]

#www.otherdomain.com and otherdomain.com will map to the folder {root}/folder2/
RewriteCond %{HTTP:Host} ^(?:www.)?otherdomain.com$
RewriteCond %{REQUEST_URI} !^/folder2/
RewriteRule ^(.*) folder2/$1 [NC,L,NS]

#subdomain.domain.com will map to the folder {root}/folder3/
RewriteCond %{HTTP:Host} ^(?:subdomain.domain.com)?$
RewriteCond %{REQUEST_URI} !^/folder3/
RewriteRule ^(.*) folder3/$1 [NC,L,NS]
于 2013-04-11T03:55:28.993 回答