zoukankan      html  css  js  c++  java
  • Yii apache配置站点出现400 Bad Request 的解决方法

    <VirtualHost *:80>
      ServerName localhost
      ServerAlias localhost
      DocumentRoot "/www/frogCms/web"
      <Directory "/www/frogCms/web/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local</Directory>
      
        # 开启 mod_rewrite 用于美化 URL 功能的支持(译注:对应 pretty URL 选项)
        RewriteEngine on
        # 如果请求的是真实存在的文件或目录,直接访问
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # 如果请求的不是真实文件或目录,分发请求至 index.php
        RewriteRule . index.php
    
        # if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
        RewriteRule ^index.php/ - [L,R=404]
    </VirtualHost>

    但是这样会出现 400 Bad Request 错误。

    解决方法:rewrite规则放到Directory中

    <VirtualHost *:80>
      ServerName localhost
      ServerAlias localhost
      DocumentRoot "/www/frogCms/web"
        <Directory "/www/frogCms/web/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
        
        # 开启 mod_rewrite 用于美化 URL 功能的支持(译注:对应 pretty URL 选项)
        RewriteEngine on
        # 如果请求的是真实存在的文件或目录,直接访问
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # 如果请求的不是真实文件或目录,分发请求至 index.php
        RewriteRule . index.php
    
        # if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
        RewriteRule ^index.php/ - [L,R=404]
        
      </Directory>
    
    </VirtualHost>

    重启apache,OK

  • 相关阅读:
    用sp_change_users_login消除Sql Server的孤立用户
    数据库连接字符串大全
    系统登录的设计与研究
    DB2常用命令大全(转)
    哈希表(HashTable)探究(转)
    转: C#实现的18位身份证格式验证算法
    通过SQLNET.ora文件限制Ip地址访问(转)
    AS/400(iSeries)
    使用Asp.Net构建安全网站
    DB2备份命名(转)
  • 原文地址:https://www.cnblogs.com/zhja/p/10607660.html
Copyright © 2011-2022 走看看