Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 防止子域使用主域';HTS访问_.htaccess_Loops_Redirect_Mod Rewrite_Subdomain - Fatal编程技术网

.htaccess 防止子域使用主域';HTS访问

.htaccess 防止子域使用主域';HTS访问,.htaccess,loops,redirect,mod-rewrite,subdomain,.htaccess,Loops,Redirect,Mod Rewrite,Subdomain,我有许多特定的301重定向从主域到子域通过htaccess。旧站点将移动到子域(从主站点),而新站点将移动到主站点。我喜欢保留旧网站的搜索引擎优化。因此,301从新站点链接到旧站点。(假设新站点上不存在301链接) 问题是子域正在访问主域的htaccess。从而导致重定向循环 一些解决方案 阻止子域访问main的htaccess 如果在main的htaccess中检测到子域地址,则退出htaccess 使个人访问成为自己独有的 我试过了。[五十] 。[完]。[北卡罗来纳州] 这是htaccess

我有许多特定的301重定向从主域到子域通过htaccess。旧站点将移动到子域(从主站点),而新站点将移动到主站点。我喜欢保留旧网站的搜索引擎优化。因此,301从新站点链接到旧站点。(假设新站点上不存在301链接)

问题是子域正在访问主域的htaccess。从而导致重定向循环

一些解决方案

  • 阻止子域访问main的htaccess
  • 如果在main的htaccess中检测到子域地址,则退出htaccess
  • 使个人访问成为自己独有的
  • 我试过了。[五十] 。[完]。[北卡罗来纳州]

    这是htaccess的子域

    Redirect 301 /changeemail https://somethingsomething
    RewriteEngine On 
    RewriteCond %{HTTP_USER_AGENT}       baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR]
    RewriteCond %{QUERY_STRING} _escaped_fragment_
    RewriteRule ^(.*)$ http://service.prerender.io/http://%{HTTP_HOST}$2 [P,L]
    
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]
    
    RewriteRule ^ /index.html`
    
    这是主域示例301


    重定向301/register www.subdomain.com/register

    您确定需要在主htaccess上重定向吗

    例如,如果您的文件结构如下:

    /域名根 /域根/mysub

    不要在/domainroot中执行重定向,只在/domainroot/mysub的htaccess上设置重定向,如下所示: 重定向匹配^/mysub/(.*)$$1


    这会将所有URL重定向到您的子域,即使是子路径。

    明白。域根的htaccess中的所有重定向都非常具体,因此没有完整的重定向。当前循环:main->sub->sub->sub->infinite。你能发布一个循环url的示例(以及被命中的重定向规则)吗?
    redirect 301/urlofthingshttp://subdomainwebsite.com/someparam
    ->这主要存在于maindomain的htaccessso上:“重定向301 www.website.com/urlofthings”主要;一旦重定向到子域,它将不再触发主域的规则。不知何故,一旦成功重定向到子域,重定向仍在发生并循环。Sub->Sub.保持当前循环。点击目标重定向url->Main的htaccess->Sub->Main的htaccess->Sub->Main的htaccess->Sub->Infinite循环