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.重启服务

  • 相关阅读:
    hdu 4710 Balls Rearrangement()
    hdu 4707 Pet(DFS水过)
    hdu 4706 Children's Day(模拟)
    hdu 4712 Hamming Distance(随机函数暴力)
    csu 1305 Substring (后缀数组)
    csu 1306 Manor(优先队列)
    csu 1312 榜单(模拟题)
    csu 1303 Decimal (数论题)
    网络爬虫
    Python处理微信利器——itchat
  • 原文地址:https://www.cnblogs.com/wangyang0210/p/10058113.html
Copyright © 2011-2022 走看看