修改网站根目录的 .htaccess 文件,当然你的服务器要支持 .htaccess <Limit GET HEAD POST> order allow,deny # Country: CHINA # ISO Code: CN # Total Networks: 1,616 # Total Subnets: 210,789,888 deny from 58.14.0.0/15 deny from 58.16.0.0/16 deny from 58.17.0.0/17 deny from 58.17.128.0/17 deny from 58.18.0.0/16 deny from 58.19.0.0/16 deny from 58.20.0.0/16 deny from 58.21.0.0/16 deny from 58.22.0.0/15 deny from 58.24.0.0/15 [...]
Tag: apache配置
apache 301跳转对seo是友好的,所以用apache的配置文件进行301跳转时很有用的。 修改 apache配置文件 例如,我现在服务器上的网站域名是 www.mytwo.com ,我又想让www.myone.com也打开www.mytwo.com,代码如下 <VirtualHost *:80> ServerName www.myone.com RedirectMatch Permanent ^/(.*) http://www.mytwo.com/$1 </VirtualHost> 另一个示例,apache虚拟主机配置示例: <VirtualHost 213.5.65.230:80> ServerAdmin cc@cc.com ServerName www.hellokey.com ServerAlias hellokey.com RedirectMatch Permanent ^/(.*) http://www.hellokeykey.com/$1 </VirtualHost> 将www.hellokey.com 301 跳转到 www.hellokeykey.com 如果使用.htaccess 来实现,直接到网址:http://www.htaccesseditor.com/sc.shtml 来设置就好了,这个是在线的傻瓜编辑器,将生成的.htaccess贴到我们的.htaccess文件就好了。 转载标明出处:hellokeykey.com 右兜钥匙
参考:http://www.askitexpert.com/question/redirect-nonwww-to-www-in-apache/10
有两种办法
1.在.htaccess的适当位置加入如下代码 yourdomain改成你的域名
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteR…
#由于是多 ip 监听同一个端口所以这样写 Listen 80 #若是多ip 多端口 则是 #Listen 192.170.2.1:80 #Listen 192.170.2.5:8000 #由于使用多ip NameVirtualHost这样设置了下,没查到详细的资料 NameVirtualHost 1.2.3.4:80 NameVirtualHost 5.6.7.8:80 #第一个ip给域名www.hellokeykey.com <VirtualHost 1.2.3.4:80> ServerAdmin key@hellokeykey.com DocumentRoot /var/www/html/hellokeykey.com ServerName www.hellokeykey.com ServerAlias hellokeykey.com </VirtualHost> #第二个ip给域名www.magentokey.com <VirtualHost 5.6.7.8:80> ServerAdmin key@hellokeykey.com DocumentRoot /var/www/html/magentokey.com ServerName www.magentokey.com ServerAlias magentokey.com </VirtualHost> 转载标明出处:hellokeykey.com 右兜钥匙
