【问题标题】:ModRewrite not working for codeigniter siteMod_Rewrite 不适用于 codeigniter 站点
【发布时间】:2011-06-09 10:46:40
【问题描述】:

我为我的 codeigniter 站点尝试了 modrewrite,但是当我进入 htaccess 文件时,已经有一个。

RewriteEngine on
RewriteCond $1 !^(index\.php?|combine\.php?|_images|assets|_styles|_js|favicon\.ico?|dashboard|mail)
RewriteRule ^(.*)$ /index.php/$1 [L]

但是,当我尝试在 xxamp 中本地测试我的网站时,我必须输入index.php,这会破坏我所有的样式链接。有什么我想念的吗?当网站上线时,它不是必需的。

编辑:这个网站是在 osx 上的 MAMP 上开发的,我在 windows 上使用 xampp,认为这可能是问题的一部分吗?

【问题讨论】:

  • 这是 codeigniter 还是 php 一般的属性?
  • mod_rewrite 是一个 Apache 模块

标签: php .htaccess codeigniter


【解决方案1】:

在我的 CI 项目中,我在 .htaccess 中有这些数据

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

【讨论】:

  • 做到了!谢谢!评论的用处很大,因为我永远猜不到这一切都做了什么。
【解决方案2】:

apache 是否在寻找 .htaccess 文件?您可能需要检查您的配置。

【讨论】:

  • httpdc.conf 说了几件事:AllowOverride All<FilesMatch "^\.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch>
猜你喜欢
  • 2016-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-30
  • 2013-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多