[英]Rewrite URL from subdomain to folder structure
I want to rewrite URL from sub domain to folder structure, like: sub.example.com to example.com which i had done successfully. 我想将URL从子域重写为文件夹结构,例如:sub.example.com到example.com,这是我成功完成的。 now i want to add a rewrite rule which will convert URL like, https://www.sub.example.com to https://www.example.com/sub . 现在,我想添加一个重写规则,该规则会将URL像https://www.sub.example.com转换为https://www.example.com/sub 。
Currently i have added following code: 目前,我已添加以下代码:
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com
RewriteRule ^(.*)$ http://example.com/%1/$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
Have it like this: 像这样:
RewriteCond %{HTTP_HOST} ^(?:www\.)?([^/]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/%1/$1 [R,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.