关于htaccess,二级域名的问题,在线等

WBOY
Release: 2016-06-23 13:51:18
Original
935 people have browsed it

各位早上好,遇到的问题是
网站,有二级域名,现在可以正常访问,但是不带www的却访问到二级的去了,
以下为.htaccess代码
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.518visa.net$
RewriteCond %{REQUEST_URI} !^/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /$1
RewriteCond %{HTTP_HOST} ^www.518visa.net$
RewriteRule ^(/)?$ / [L]
#以下为二级,如果有更简单的希望指教,谢谢
RewriteCond %{HTTP_HOST} ^([A-Za-z]*[^www\b]).518visa.net$
RewriteCond %{REQUEST_URI} !^visalist/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^([A-Za-z]*[^www\b]).518visa.net$
RewriteRule ^([1-9]\d*).html($) visalist/visa_detail.php?id=$1
RewriteRule ^(/)?$ visalist/ [L]

网址为www.518visa.net,非外链广告,麻烦看看,谢谢了。
下图红框选中的,点进去为二级域名


我现在需要的就是不带www访问时直接转到带www,如abc.com/a.html转到www.abc.com/a.html,我用了
RewriteCond %{HTTP_HOST} !^www.518visa.net$ [NC]
RewriteRule ^(.*)$ http://www.518visa.net/$1 [L,R=301]
这个也不行
谢谢了,在线等


回复讨论(解决方案)

我用的是如下:

#301RewriteCond %{HTTP_HOST} ^xxx.net [nc]RewriteRule ^(.*)$ http://www.xxx.net/$1 [L,R=301]#aaaa.xxx.net - is OKRewriteCond %{HTTP_HOST} (?!www|ww)^[a-z0-9\-]+.xxx.net$RewriteRule ^/?$ /%{HTTP_HOST}RewriteRule ^/([a-z0-9\-]+).xxx.net$      /1.php?keyword=$1
Copy after login


如果不行, 你看看你的apache里面的documentroot设置了什么
如果还不行, 你可以考虑用变通的方法。 
建立一个xxx.net的web,然后在这个web里面做一个htaccess 301到www

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!