htaccess的重定向子域域重定向、htaccess、子域域

由网友(知南茶温暖)分享简介:有很多与此相关的主题帖。但找到一个完全一样将花费大量的时间。所以生病只是简单地问agian如果已经问过。 我想这样的somename.mysite.com一个URL重定向到像mysite.com/test/somename的URL。注意somename是一个daynamic价值,我怎么能写的htaccess的rewri...

有很多与此相关的主题帖。但找到一个完全一样将花费大量的时间。所以生病只是简单地问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>
 
.htaccess文件的常见用法 301 404等配置

在哪里我把你给我的答案。

感谢您事先的任何帮助。

解决方案

 < 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>

阅读全文

相关推荐

最新文章