LAMP和LNMP去除index.php访问
生活随笔
收集整理的這篇文章主要介紹了
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.重啟服務
轉載于:https://www.cnblogs.com/wangyang0210/p/10058113.html
總結
以上是生活随笔為你收集整理的LAMP和LNMP去除index.php访问的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ansible基础-Jinja2模版 |
- 下一篇: 有序链表转换二叉搜索树(LeetCode