gpt4 book ai didi

php - CodeIgniter + mod_rewrite url重写错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:09:15 25 4
gpt4 key购买 nike

我在Windows(使用WampServer)上使用CodeIgniter和mod_rewrite(仅抽象索引)创建了一个应用程序。在这种环境下,该应用程序运行得很好,一切都很顺利。但当我将其移植到生产服务器(Linux)时,重写过程就停止了。

乍一看,我觉得 Linux 文件系统的“区分大小写”是罪魁祸首。但在重命名包含错误的文件后,问题仍然存在。

事实是。无论我调用哪个 url,重写都会不断调用/index.php。

这是我的 .htaccess 内容:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
RewriteRule .\svn\* - [F]

我的应用程序的文件夹结构是:

doc_root
- application
-controllers
-c.php

- .htaccess
- index.php
(... everything else is codeigniter's default)

最佳答案

    <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller
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]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>

关于php - CodeIgniter + mod_rewrite url重写错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19911780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com