htaccess的重定向子域域 [英] htaccess redirect subdomain to domain
问题描述
有很多与此相关的主题帖。但找到一个完全一样将花费大量的时间。所以生病只是简单地问agian如果已经问过。
我想这样的somename.mysite.com一个URL重定向到像mysite.com/test/somename的URL。注意somename是一个daynamic价值,我怎么能写的htaccess的rewrite_rule?
在htaccess的文件已经有一些:
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
重写规则^指数\ .PHP $ - [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
< / IfModule>
在哪里我把你给我的答案。
感谢您事先的任何帮助。
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{HTTP_HOST} ^(\ W +)\。mysite的\ .COM [NC]
重写规则。* http://mysite.com/test/%1 [R,L]
重写规则^指数\ .PHP $ - [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
< / IfModule>
there are a lot of posts related to this topic. but finding one exactly the same will take a lot of time. so Ill just simply ask agian if this has been asked before.
I would like to redirect a url like this "somename.mysite.com" to a url like "mysite.com/test/somename". notice the "somename" is a daynamic value, how can I write the rewrite_rule in htaccess?
in htaccess file there is already something:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
where do I place the answer you give me.
Thank you for any help in advance.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(\w+)\.mysite\.com [NC]
RewriteRule .* http://mysite.com/test/%1 [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
这篇关于htaccess的重定向子域域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!