需要使用htaccess的同一个域中的重定向像子域文件夹 [英] Need to redirect folders like sub-domain within same domain using htaccess
本文介绍了需要使用htaccess的同一个域中的重定向像子域文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我的网址是如 http://vidleap.com/nov5and151/index.html 现在我想重定向这个URL如 http://nov5and151.vidleap.com/index.html。因此,如何通过htaccess的做到这一点?
我使用跌破code,但它不工作。
< IfModule mod_rewrite.c>
< IfModule mod_negotiation.c>
选项-MultiViews
< / IfModule>
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^的index.php [QSA,L]
的RewriteCond%{HTTP_HOST} ^(?:WWW \)?vidleap \ .COM [NC]
重写规则^([^ /] +)(/.*)$ HTTP://www.$1.vidleap.com$2 [R = 301,L,NC]
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)\。vidleap \ .COM [NC]
重写规则^(。*)$ / 1%/ $ 1 [L]
< / IfModule>
解决方案
在尝试不同的顺序规则:
< IfModule mod_negotiation.c>
选项-MultiViews
< / IfModule>
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME -f [OR]
的RewriteCond%{} REQUEST_FILENAME -d
重写规则^ - [L]
的RewriteCond%{HTTP_HOST} ^(?:WWW \)?域\ .COM [NC]
重写规则^([^ /] +)(/.*)$ HTTP://www.$1.domain.com$2 [R = 301,L]
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)\。域\ .COM [NC]
重写规则^(。*)$ / 1%/ $ 1 [L]
重写规则^的index.php [L]
确认清除浏览器缓存。
Currently my URL is like http://vidleap.com/nov5and151/index.html and now I want to redirect this URL like http://nov5and151.vidleap.com/index.html. So how to do it via htaccess?
I am using below code but it's not working.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
RewriteCond %{HTTP_HOST} ^(?:www\.)?vidleap\.com [NC]
RewriteRule ^([^/]+)(/.*)?$ http://www.$1.vidleap.com$2 [R=301,L,NC]
RewriteCond %{HTTP_HOST} ^www\.(.+)\.vidleap\.com [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
</IfModule>
解决方案
Try these rules in different order:
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.com [NC]
RewriteRule ^([^/]+)(/.*)?$ http://www.$1.domain.com$2 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.+)\.domain\.com [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
RewriteRule ^ index.php [L]
Make sure to clear your browser cache.
这篇关于需要使用htaccess的同一个域中的重定向像子域文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文