.htaccess将规则subsubdomain.subdomain.domain.tld重写为subdomain.domain.tld/subsubdomain
是否可以使用.htaccess重写规则将子域重定向到子域,并将子域作为新文件夹 例如。。。当我转到2013.archive.example.com时,我想在archive.example.com/2013中结束 已尝试了一些操作,当前。htaccess是:.htaccess将规则subsubdomain.subdomain.domain.tld重写为subdomain.domain.tld/subsubdomain,.htaccess,redirect,mod-rewrite,dns,subdomain,.htaccess,Redirect,Mod Rewrite,Dns,Subdomain,是否可以使用.htaccess重写规则将子域重定向到子域,并将子域作为新文件夹 例如。。。当我转到2013.archive.example.com时,我想在archive.example.com/2013中结束 已尝试了一些操作,当前。htaccess是: RewriteRule On RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$ RewriteRule ^(.*)$ archive.example.com/%1/$1 [L] 不
RewriteRule On
RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$
RewriteRule ^(.*)$ archive.example.com/%1/$1 [L]
不幸的是,它不起作用。对此有什么建议吗?外部重定向:(浏览器中的URL更改) 您可以在
文档\u ROOT/.htaccess
中使用此规则:
RewriteCond %{HTTP_HOST} ^([^.]+)\.(archive\.example\.com)$ [NC]
RewriteRule ^ http://%2/%1%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^([^.]+)\.archive\.example\.com$ [NC]
RewriteRule ^ /%1%{REQUEST_URI} [L]
如果DOCUMENT\u ROOT
与anywhere.archive.example.com
和archive.example.com
相同,则这将起作用
用于内部转发:(浏览器中没有URL更改)
您可以在文档\u ROOT/.htaccess
中使用此规则:
RewriteCond %{HTTP_HOST} ^([^.]+)\.(archive\.example\.com)$ [NC]
RewriteRule ^ http://%2/%1%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^([^.]+)\.archive\.example\.com$ [NC]
RewriteRule ^ /%1%{REQUEST_URI} [L]
如果它们共享同一根,则您不需要规则目标中的
archive.example.com
部分:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$ [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
已将其更改为,但当前使用:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$ [NC]
RewriteRule ^(.*)$ %1/$1 [L]
并且正按照我想要的方式工作:)所有子域是否共享同一个文档根目录?还有一些其他子域。。。但url就像2011.archive.example.com,2012.archive.example.com,2013.archive。。etc共享archive.example的根目录。com@anubhava
DOCUMENT\u ROOT
是archive
或example.com
?应该是指向example.com
的目录。