URL重定向到子域而不更改地址中的URL
问题描述:
我是Linux新手,希望使用.htaccess或代理服务器进行URL重定向,使URL与apache2保持不变。URL重定向到子域而不更改地址中的URL
现在我想将我的主域http://example.com/test重定向到我的子域http://test.example.com而不更改地址栏中的网址。
请帮助我,给我带的.htaccess或代理或者一些其他的一些准则..
答
如果你不想要的网址来改变您可能需要两个虚拟主机之间的反向代理服务器建立/域,或者如果example.com只是一个别名,相同的IP并从相同的Apache虚拟主机提供服务,则可以使用内部重写。更多信息HERE
你也可以试试这个。更多的Infor去HERE
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^/?(index.\php)?$ /category [L]
这只能为http://domain.com/或http://domain.com/index.php请求,并且你会得到服务内容在http://domain.com/category没有在地址栏中更改URL。如果您不需要它,甚至可能会丢失RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
[NC]行。
也有到服务器有用的资源here
RewriteEngine on
RewriteBase/
######## example.com ########
RewriteCond %{HTTP_HOST} ^.*example.com$ [NC]
RewriteCond /www/quux-foo.com/www/root/v1%{REQUEST_URI} -d
RewriteRule ^(.*[^/])$ %{REQUEST_FILENAME}/ [L]
RewriteCond %{HTTP_HOST} ^.*quux-foo.com$ [NC]
RewriteCond %{REQUEST_URI} ^/v1/
RewriteRule ^(.*)$ - [F]
RewriteCond %{HTTP_HOST} ^.*example.com$ [NC]
RewriteCond /www/quux-foo.com/www/root/v1%{REQUEST_URI} -f [OR]
RewriteCond /www/quux-foo.com/www/root/v1%{REQUEST_URI} -d
RewriteRule ^(.*)$ v1/$1 [L]
RewriteCond %{HTTP_HOST} ^.*example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/v1/
RewriteRule ^(.*)$ v1/index.php [L]
######## example.com ########
感谢您的快速反应MAYUR,我想http://example.com/test http://test.example.com/的内容 为此,我需要一个重定向代码。我可以通过将index.php放入带有标题代码的类别文件夹中来重定向网页。但我不想改变什么网址。它必须将URL显示为http://example.com/test – Srikanth1239 2013-04-05 09:21:15