簡體   English   中英

CodeIgniter:使用.htaccess重寫URL

[英]CodeIgniter: rewriting URL's with .htaccess

我已經使用CodeIgniter和多個控制器構建了一個應用程序

我希望應用程序URL通過使用.htaccess文件看起來“漂亮”。
除了在“ application / config / routes.php”文件中設置為默認值的控制器外,所有控制器似乎都可以正常工作

我的.htaccess文件如下所示:

RewriteEngine開
RewriteBase /
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ /index.php/$1 [L]

我也像這樣設置了config.php文件

$ config ['index_page'] ='';

在服務器日志中,我得到這樣的錯誤:

[2013年11月29日星期五10:32:11] [錯誤] [客戶端 ] mod_security:根據POST有效負載進行過濾,但有效負載不可用[主機名“ app。 * .nl”] [uri“ /用戶/配置文件]]

在開發服務器上,一切正常,但由於應用程序在生產服務器上,因此無法與.htaccess文件一起使用。

AddDefaultCharset UTF-8

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} ^codeigniter.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM