這篇文章主要介紹了CodeIgniter針對lighttpd服務器URL重寫的方法,涉及lighttpd服務器配置及URL配置規則的相關技巧,需要的朋友可以參考下
本文實例講述了CodeIgniter針對lighttpd服務器URL重寫的方法。分享給大家供大家參考。具體實現方法如下:
由于開發環境使用的是lighttpd服務器,我本機環境使用的是Apache配置,導致部署到開發機后,所有的鏈接地址全部跳轉到首頁。
分析了下,index.php/controller/function ,controller沒有生效,應該是路由分發的緣故。
配置lighttpd配置的url重寫規則:
- url.rewrite-once = (
- "/(.*)/.(.*)" => "$0",
- "/(css|files|img|js|stats)/" => "$0",
- "^/([^.]+)$" => "/index.php/$1"
- )
另附Apache url重寫規則:
- <VirtualHost *:80>
- ProxyPreserveHost On
- DocumentRoot "D:/Program Files/xampp/htdocs/xxx"
- ServerName xxx.baidu.com
- DirectoryIndex index.php
- <Directory "D:/Program Files/xampp/htdocs/xxx">
- Options Indexes FollowSymLinks
- AllowOverride All
- Order allow,deny
- Allow from all
- </Directory>
- </VirtualHost>
重啟lighttpd服務,ok!
希望本文所述對大家基于CodeIgniter的php程序設計有所幫助。
新聞熱點
疑難解答