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

  • 相关阅读:
    PTA(Advanced Level)1037.Magic Coupon
    PTA(Advanced Level)1033.To Fill or Not to Fill
    PTA(Basic Level)1020.月饼
    PTA(Advanced Level)1048.Find Coins
    PTA(Advanced Level)1050.String Subtraction
    PTA(Advanced Level)1041.Be Unique
    PTA(Basci Level)1043.输出PATest
    PTA(Basic Level)1039.到底买不买
    PTA(Basic Level)1033.旧键盘打字
    PTA(Advanced Level)1083.List Grades
  • 原文地址:https://www.cnblogs.com/zhja/p/10607660.html
Copyright © 2011-2022 走看看