[英].htaccess RewriteRule subsubdomain.subdomain.domain.tld to subdomain.domain.tld/subsubdomain
Is it posible to redirect a sub-subdomain into a subdomain with the sub-sub domain as new folder using .htaccess rewrite-rule? 是否可以使用.htaccess rewrite-rule将子子域重定向到子域,子域为新文件夹?
For example... When i go to 2013.archive.example.com I want to end up in archive.example.com/2013.. 例如......当我去2013.archive.example.com我想最终进入archive.example.com/2013 ..
Already tried some things, current .htaccess is: 已经尝试了一些东西,目前.htaccess是:
RewriteRule On
RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$
RewriteRule ^(.*)$ archive.example.com/%1/$1 [L]
Unfortunately it isn't working. 不幸的是它不起作用。 Any suggestions for this?
有什么建议吗?
Changed it a but, currently using: 改了一个但是,目前正在使用:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$ [NC]
RewriteRule ^(.*)$ %1/$1 [L]
and is working exactly how I wanted:) 并正在工作我想要的:)
For external redirect: (URL change in browser) 对于外部重定向:(浏览器中的URL更改)
You can use this rule in your DOCUMENT_ROOT/.htaccess
: 您可以在
DOCUMENT_ROOT/.htaccess
使用此规则:
RewriteCond %{HTTP_HOST} ^([^.]+)\.(archive\.example\.com)$ [NC]
RewriteRule ^ http://%2/%1%{REQUEST_URI} [L,R=301]
This will work provided DOCUMENT_ROOT
is same for anything.archive.example.com
and archive.example.com
. 只要
DOCUMENT_ROOT
与anything.archive.example.com
和archive.example.com
相同,这将有效。
For internal forward: (No URL change in browser) 对于内部转发:(浏览器中没有URL更改)
You can use this rule in your DOCUMENT_ROOT/.htaccess
: 您可以在
DOCUMENT_ROOT/.htaccess
使用此规则:
RewriteCond %{HTTP_HOST} ^([^.]+)\.archive\.example\.com$ [NC]
RewriteRule ^ /%1%{REQUEST_URI} [L]
If they share the same root, then you don't need the archive.example.com
part in your rule's target: 如果它们共享相同的根,那么您的规则目标中不需要
archive.example.com
部分:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.archive\.example\.com$ [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.