zoukankan      html  css  js  c++  java
  • LAMP和LNMP去除index.php访问

    使用TP或者Laravel开发的时候,后时候会遇到需要加index.php才能正常访问

        

    LAMP解决方法

        1.修改配置

          打开配置文件(如:httpd.conf),找到你网站根目录的配置,将AllowOverride这项改为all

        2.重启服务

    <Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride all 这个就是
    Require all granted
    </Directory>

      LNMP解决办法

        1.编辑配置文件

          

    vi /usr/local/nginx/conf/vhost/虚拟主机名字.conf
    #注释 
    include enable-php.conf (或者直接dd删除)
    #添加
    include enable-php-pathinfo.conf; #注意后面必须带分号
    #在server段添加
    location / {
    if (!-e $request_filename){
    rewrite ^/(.*)$ /index.php/$1 last;
    }
    }

    完整配置文件

    server
        {
            listen 80;
            #listen [::]:80;
            server_name www.wangnana.cn wangnana.cn;
            index index.html index.htm index.php default.html default.htm default.php;
            root  /home/wwwroot/www.wangnana.cn/public;
    
            include rewrite/none.conf;
            #error_page   404   /404.html;
    
            # Deny access to PHP files in specific directory
            #location ~ /(wp-content|uploads|wp-includes|images)/.*.php$ { deny all; }
         #这一段
            include enable-php-pathinfo.conf;  
             #include enable-php.conf;
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.well-known {
                allow all;
            }
    
            location ~ /.
            {
                deny all;
            }
    #这一段 location
    / { if (!-e $request_filename){ rewrite ^/(.*)$ /index.php/$1 last; } } access_log /home/wwwlogs/www.wangnana.cn.log; }

      

      2.重启服务

  • 相关阅读:
    Windows 上如何安装Sqlite
    StringBuffer类讲解
    Android Debug Bridge(adb)百度
    0117调试 (Logout调试)
    android cmd adb shell 出现 Device offline的状态下
    菜鸟:为什么要用不同的包 android
    0105Activity+Intent
    adb shell 后感
    0116sqlite
    iptables
  • 原文地址:https://www.cnblogs.com/wangyang0210/p/10058113.html
Copyright © 2011-2022 走看看