laravel 去掉index.php伪静态的操作方法

2019-11-0707:44:00后端程序开发Comments2,908 views字数 1118阅读模式

1、首先,让apache服务器支持rewrite文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

可以在apache配置文件中定义rewrite规则,是全局的,无论哪个应用都实用文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

//ig

Listen 80

RewriteEngine on ---将rewrite开启

LoadModule rewrite_module modules/ 前面的注释去掉

在Directory中配置:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

<Directory "/www/poem/public">

Options Indexes FollowSymLinks

AllowOverride All ----这项一定要进行修改

Order deny,allow

Allow from all

</Directory>

2、配置.htaccess文件 ---find / -name .htaccess 来查找此文件文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

<IfModule mod_rewrite.c>

Options +FollowSymLinks

RewriteEngine On

</IfModule>

<IfModule mod_rewrite.c>

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ $1 [L] ---这句话的含义是:任何访问网站的路径都映射成xxx,其中xxx是$1 与 (.*)中的内容进行匹配 例如我们输入http://192.168.0.222/about -->http://192.168.0.222/about文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

</IfModule>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

3、如果是专门针对laravel进行配置,则在app/中加入文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

index=>'', //中没有此项,直接手写加入即可文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

如果还不行文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

先在注释掉文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

#<Directory />
# Options FollowSymLinks
# AllowOverride All 
# Order deny,allow
# Deny from all
#</Directory>

然后在httpd-vhost修改如下,文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html

<VirtualHost *:80>
 ServerAdmin none@none.com
 DocumentRoot "E:/www/learnlaravel5/public"
 ServerName le
 DirectoryIndex  index.html
 ErrorLog "logs/"
 CustomLog "logs/" common
 <Directory "E:/www/learnlaravel5/public">
 Options -Indexes +FollowSymLinks
 AllowOverride all
 Order allow,deny
 Allow from all
 #Require all granted
 </Directory>
</VirtualHost>
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/17386.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/17386.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定