[英]CodeIgniter all the pages redirecting to home page?
我已经做了一个codeIgniter应用程序。 它在我的本地环境下工作非常好,但是当我将其部署到主页面时,我的所有页面都将重定向到主页。
我有以下目录结构:
- -万维网
-----的.htaccess
------ codeIgniter(该应用程序位于此处)。
我的htaccess内容如下
RewriteEngine on
RewriteCond $1 ^media
RewriteRule ^(.*)$ codeIgnite/$1
RewriteCond $1 !^(index\.php|codeIgnite|images|robots\.txt)
RewriteRule ^(.*)$ codeIgnite/index.php/$1
这是我的config.php $config['base_url'] = "http://localhost/codeIgnite/";
//还是应该只是http:// localhost / ?
还有其他一些我需要更改的配置设置吗? 请帮忙。
我的主页显示正常。 问题出在其他页面上。 无论我提供什么URL,我都会看到我的主页UI。
设置$ config ['uri_protocol'] =“ ORIG_PATH_INFO”,可解决此问题。
我使用了CodeIgniter提供的.htaccess ,只是将RewriteBase
设置到我的子目录中,以使其正常工作。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeIgnite/
#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]
</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>
您应该将.htaccess放在CodeIgniter文件夹中,还必须将文件的最后一行修改为此RewriteRule ^(。 )$ /codeIgniter/index.php/$1或RewriteRule ^(。 )$ / codeIgnite / index.php / $ 1您无需在apache配置中执行任何操作,只需打开扩展名rewrite_module
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.