标签:
最近几天准备做个小项目,使用国内的某平台进行版本控制、项目演示、质量管理。由于使用的是laravel框架,项目入口在public目录下,演示平台又不提供修改网站根目录的功能权限。那么能不能通过rewrite来搞定呢?
度娘不给力,半天没找到能用的规则。那么只能自己写了,我写rewrite是个半吊子,尝试许久还是没搞定,主要原因是没有有效的办法进行调试,只能瞎蒙。。。
后来问度娘怎么开启Apache的rewrite日志,大都是这样的:
RewriteLog "/myfolder/mylogfile.log"
RewriteLogLevel 9
Apache起不来,看日志是这样的
Syntax error on line 162 of /Applications/XAMPP/xamppfiles/etc/httpd.conf:
Invalid command ‘RewriteLog‘, perhaps misspelled or defined by a module not included in the server configuration
淡定不了了,翻手册去吧,http://httpd.apache.org/docs/current/mod/mod_rewrite.html
原来是这样设置的:LogLevel rewrite:trace3,日志去看ErrorLog所指向的文件。
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
LogLevel rewrite:trace3
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
日志是这样的:
[Wed Apr 22 19:40:30.641932 2015] [rewrite:trace3] [pid 5718] mod_rewrite.c(475): [client 127.0.0.1:50136] 127.0.0.1 - - [test.me/sid#10085e000][rid#1008c9260/initial/redir#1] [perdir /Users/MLS/mineObj/hellolumen/] strip per-dir prefix: /Users/MLS/mineObj/hellolumen/index.php -> index.php
[Wed Apr 22 19:40:30.641956 2015] [rewrite:trace3] [pid 5718] mod_rewrite.c(475): [client 127.0.0.1:50136] 127.0.0.1 - - [test.me/sid#10085e000][rid#1008c9260/initial/redir#1] [perdir /Users/MLS/mineObj/hellolumen/] applying pattern ‘^(.*)/$‘ to uri ‘index.php‘
[Wed Apr 22 19:40:30.641969 2015] [rewrite:trace3] [pid 5718] mod_rewrite.c(475): [client 127.0.0.1:50136] 127.0.0.1 - - [test.me/sid#10085e000][rid#1008c9260/initial/redir#1] [perdir /Users/MLS/mineObj/hellolumen/] strip per-dir prefix: /Users/MLS/mineObj/hellolumen/index.php -> index.php
OK!有了日志就好办了,接下来慢慢调罢。
我相信是能够通过rewrite来解决laravel在部署到入口非public的环境的问题的。
时间不早了,先回家吃饭,等有结果了再贴过来。欢迎懂的朋友反馈
标签:
原文地址:http://my.oschina.net/janfon/blog/405211