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

所属分类: 网络编程 / PHP编程 阅读数: 417
收藏 0 赞 0 分享

1、首先,让apache服务器支持rewrite

可以在apache配置文件中定义rewrite规则,是全局的,无论哪个应用都实用

//httpd.config

Listen 80

RewriteEngine on ---将rewrite开启

LoadModule rewrite_module modules/mod_rewrite.so 前面的注释去掉

在Directory中配置:

<Directory "/www/poem/public">

Options Indexes FollowSymLinks

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

Order deny,allow

Allow from all

</Directory>

2、配置.htaccess文件 ---find / -name .htaccess 来查找此文件

<IfModule mod_rewrite.c>

Options +FollowSymLinks

RewriteEngine On

</IfModule>

<IfModule mod_rewrite.c>

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L] ---这句话的含义是:任何访问网站的路径都映射成index.php/xxx,其中xxx是$1 与 (.*)中的内容进行匹配 例如我们输入http://192.168.0.222/about -->http://192.168.0.222/index.php/about

</IfModule>

3、如果是专门针对laravel进行配置,则在app/app.php中加入

index=>'', //laravel4.1中没有此项,直接手写加入即可

如果还不行

先在httpd.conf注释掉

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

然后在httpd-vhost修改如下,

<VirtualHost *:80>
 ServerAdmin none@none.com
 DocumentRoot "E:/www/learnlaravel5/public"
 ServerName le
 DirectoryIndex index.php index.html
 ErrorLog "logs/dummy-host.2012-20090214YX.domain-error.log"
 CustomLog "logs/dummy-host.2012-20090214YX.domain-access.log" common
 <Directory "E:/www/learnlaravel5/public">
 Options -Indexes +FollowSymLinks
 AllowOverride all
 Order allow,deny
 Allow from all
 #Require all granted
 </Directory>
</VirtualHost>

以上这篇laravel 去掉index.php伪静态的操作方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

更多精彩内容其他人还在看

PHP.MVC的模板标签系统(四)

PHP.MVC的模板标签系统(四)
收藏 0 赞 0 分享

PHP.MVC的模板标签系统(五)

PHP.MVC的模板标签系统(五)
收藏 0 赞 0 分享

Windows下的PHP5.0安装配制详解

Windows下的PHP5.0安装配制详解
收藏 0 赞 0 分享

最令PHP初学者头痛的十四个问题

最令PHP初学者头痛的十四个问题
收藏 0 赞 0 分享

PHP中的串行化变量和序列化对象

PHP中的串行化变量和序列化对象
收藏 0 赞 0 分享

PHP 5.0对象模型深度探索之绑定

PHP 5.0对象模型深度探索之绑定
收藏 0 赞 0 分享

PHP5.0对象模型探索之抽象方法和抽象类

PHP5.0对象模型探索之抽象方法和抽象类
收藏 0 赞 0 分享

PHP在XP下IIS和Apache2服务器上的安装

PHP在XP下IIS和Apache2服务器上的安装
收藏 0 赞 0 分享

初学者入门:细述PHP4的核心Zend

初学者入门:细述PHP4的核心Zend
收藏 0 赞 0 分享

PHP环境搭建最新方法

PHP环境搭建最新方法
收藏 0 赞 0 分享
查看更多