科技常识:windows中apache 301页面跳转实现方法

2021-04-03 15:42:45
导读 今天小编跟大家讲解下有关科技常识:windows中apache 301页面跳转实现方法,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关科

今天小编跟大家讲解下有关科技常识:windows中apache 301页面跳转实现方法,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关科技常识:windows中apache 301页面跳转实现方法的相关资料,希望小伙伴会喜欢也能够帮助大家。

实现301页面跳转之前需要对apache配置做下修改如 apache默认是没有开启mod_rewrite模块的, 1,将 复制代码 代码如下: #LoadModule rewrite_module modules/mod_rewrite.so 这一行前面的#号去掉,http.conf的站点目录配置,另一种是空间用户常用的 改为 复制代码 代码如下:LoadModule rewrite_module modules/mod_rewrite.so, 2,将AllowOverride None 改为:AllowOverride All 一、写.htaccess文件,关于301重定向的写法: 1) 常见的将不带WWW的域名转向到带WWW的域名下 举例:网站.com重定向到www.网站.com 复制代码 代码如下: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^网站.com [NC] RewriteRule ^(.*)$ http://www.网站.com/$1 [L,R=301] 如果你有服务器权限我们可以在http.conf中修改 二、Apache下vhosts.conf中配置301转向。 复制代码 代码如下: <VirtualHost *:80> DocumentRoot “E:/xxx” ServerName http://www.域名.net </VirtualHost> <VirtualHost *:80> ServerName 域名.net RedirectMatch permanent ^/(.*) http://www.域名.net$1 </VirtualHost> 例 将不带WWW的域名转向到带WWW的域名下 复制代码 代码如下: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^xxx.cn [NC] RewriteRule ^(.*)$ http://www.xxx,cn/$1 [L,R=301] 常用的客户端请求错误返回代码: 400 - Bad request 错误请求 401 Authorization Required需要验证 403 Forbidden禁止 404 Not Found找不到页面 405 Method Not Allowed 408 Request Timed Out 411 Content Length Required 412 Precondition Failed 413 Request Entity Too Long 414 Request URI Too Long 415 Unsupported Media Type 大家可使用ff浏览firebug来检测是否返回了301状态代码

来源:爱蒂网

免责声明:本文由用户上传,如有侵权请联系删除!

猜你喜欢

最新文章