2012-01-10 79 views
0

晚上好, 我想知道是否有可能将请求重定向到我的页面http://test.diogo.me到页面的内容为 - >http://www.diogo.me/pages/test/(此重定向必须是内部的...浏览器应该指向http://test.diogo.me)。 我一直在阅读有关.htaccess,我觉得这是我的决议。
我试图用下面的代码:内部重定向 - PHP和.htaccess?

<IfModule mod_rewrite.c> 
RewriteCond %{HTTP_HOST} !^www\.diogo\.me [NC] 
RewriteCond %{HTTP_HOST} ([^.]+)\.diogo\.me [NC] 
RewriteRule ^(.*)$ /%1/$1 [L] 

输出是错误404文件未找到:(
我在正确的轨道去
对不起我的表达限制在此先感谢

回答

0

?只要把这个代码在你的.htaccess和删除您现有的生产线从那里:

Options +FollowSymLinks -MultiViews 
RewriteEngine on 

RewriteCond %{HTTP_HOST} ^test\.diogo\.me$ [NC] 
RewriteRule ^$ http://www.diogo.me/pages/test/ [L,P] 
+2

或者你可以替换'P'到代理'R',所以浏览器仍然说http://test.diogo.me/ – 2012-01-10 06:11:13

+0

非常感谢@JonLin,编辑我的答案使用'P'而非' R'。 – anubhava 2012-01-10 08:40:33

+0

感谢支持@anubhava和Jon Lin。此代码不起作用,所以它可能与我的服务器的配置有关? – 2012-01-10 10:17:28

0

你失踪的/pages部分

RewriteCond %{HTTP_HOST} !^www\.diogo\.me [NC] 
RewriteCond %{HTTP_HOST} ([^.]+)\.diogo\.me [NC] 
RewriteRule ^(.*)$ /pages/%1/$1 [L] 

假设子域具有相同的文档根作为主域。

+0

我的整个htaccess的:' RewriteEngine叙述上 的RewriteCond%{HTTP_HOST}^WWW \ .diogomend \ .ME [NC] 的RewriteCond%{HTTP_HOST}([^。] +)\ diogomend \!。 .me [NC] RewriteRule ^(。*)$/pages /%1/$ 1 [L] '并且它仍然不起作用。该请求甚至不会显示在我的access.log中 – 2012-01-10 14:51:54