我想更改我的网站的URL结构,我需要进行一些重定向,基本上我想要:
www.root.com/folder/second_folder/file.php重定向到folder.root.com/second_folder/file.php
反正我是否可以强制将第一个网址重定向到子网址网址? 我还有一些特定的根URL,我想重定向到子域中的特定文件夹。
我尝试了各种方法,到目前为止没有任何工作,但只能将我的htaccess文件放在根文件夹中。 如果我将它放在我的子域文件夹中,那么它会将它们全部分开。
谢谢。
I want to change the URL structure of my site, and I need to make some redirects, basically i want:
www.root.com/folder/second_folder/file.php to redirect to folder.root.com/second_folder/file.php
Is there anyway that I could force to redirect the first url, to the subdomain url? I also have some specific root URL's that I want to redirect to specific folders in the subdomain.
I tried various ways and nothing works so far, but only by placing my htaccess file in the root folder. If I place it in my subdomain folder, then it breaks all together.
Thank you.
最满意答案
将此代码放在DOCUMENT_ROOT/.htaccess文件中:
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?root\.com$ RewriteRule ^([^/]+)/(.+?\.php)$ http://$1.root.com/$2 [L,R=301,NE]Place this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?root\.com$ RewriteRule ^([^/]+)/(.+?\.php)$ http://$1.root.com/$2 [L,R=301,NE]更多推荐
发布评论