Home > Backend Development > PHP Tutorial > 哪位高手帮小弟我发个.htaccess域名传向文件?为什么这个不行

哪位高手帮小弟我发个.htaccess域名传向文件?为什么这个不行

WBOY
Release: 2016-06-13 10:10:32
Original
857 people have browsed it

谁帮我发个.htaccess域名传向文件?为什么这个不行?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.xxx.com$ [OR]RewriteCond %{HTTP_HOST} ^xxx.com$ 
RewriteRule ^/?$ "http\:\/\/www\.example\.com" [R=301,L]

谁帮我发个.htaccess域名传向文件?为什么这个不行?

同时绑定在一个空间里的有五个域名1.www.example.com,2.www.xxx.com,3.xxx.com,4.bbs.example.com;5.news.example.com;
要实现的功能:
当用www.xxx.com,xxx.com来访问时,自动跳转至www.example.com(地址栏域名显示成www.example.com)指向空间主页面index.php。
当bbs.example.com来访问时,指向www.example.com/bbs 子页面;(地址栏域名显示成bbs.example.com)。
当news.example.com来访问时,指向www.example.com/news 子页面;(地址栏域名显示成news.example.com)。



------解决方案--------------------
域名跳转没试过。。。是不是你没开启.htaccess目录识别?
子页跳转的话可以用这个
RewriteCond %{HTTP_HOST} ^bbs.example.com$
RewriteCond %{REQUEST_URI} !^/bbs/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /bbs/$1
RewriteCond %{HTTP_HOST} ^bbs.example.com$
RewriteRule ^(/)?$bbs/index.php [L]
------解决方案--------------------
域名转向?是不是就是跳转呢?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template