我有点删除了.htacess
上的一行现在我无法打开support.sitename.com
这是我的支持文件夹, 的的public_html /支撑
但如何将其重定向到 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]
答案 0 :(得分: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 ,您最好使用这些条件并对您的<进行规则em> .htaccess 文件:
RewriteCond %{HTTP_HOST} !^(www\.)?support\.sitename\.com$
RewriteRule ^support/?$ http://support.sitename.com/
答案 1 :(得分:0)
试试此代码段
RewriteEngine on
RewriteCond %{HTTP_HOST} ^m\.example\.com$
RewriteRule ^ http://example.com/m%{REQUEST_URI} [L,P]
答案 2 :(得分:0)
我发现了这个:redirect support.example.com to 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]