• 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

  • 相关阅读:
    228. Summary Ranges
    227. Basic Calculator II
    224. Basic Calculator
    222. Count Complete Tree Nodes
    223. Rectangle Area
    221. Maximal Square
    220. Contains Duplicate III
    219. Contains Duplicate II
    217. Contains Duplicate
    Java编程思想 4th 第4章 控制执行流程
  • 原文地址:https://www.cnblogs.com/zhja/p/10607660.html
Copyright © 2020-2023  润新知