在我的旧网址中,它是http://localhost/midas/index.php
我的网站正在使用CodeIgniter的MVC框架。
我在Apache XAMPP中激活了mod_rewrite并使用了以下htaccess代码:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [NC,R=301,L]
当我输入我的基本网址时,它很好,我的主页加载:
base url = http://localhost/midas/
然而,当我点击导航菜单或链接时,我收到404找不到对象的错误消息。
Apache错误消息:
[Tue Jul 12 13:48:55 2011] [错误] [client 127.0.0.1]文件不存在:C:/ xampp / htdocs / midas / site,referer:http://localhost/midas/
我需要在某处更改某些内容吗?
答案 0 :(得分:1)
修改/application/config/config.php
并更改
$config['index_page'] = 'index.php';
到
$config['index_page'] = '';
此外,在启用mod_rewrite
后,您需要重新启动Apache。
这是我在CodeIgniter中使用的.htaccess
(已修改,因此它适合您):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /midas/
#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
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
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>
它应该在您的根目录中(即C:\xampp\htdocs\midas
)。
答案 1 :(得分:0)
您可能需要在htaccess中设置RewriteBase
请参阅:http://httpd.apache.org/docs/current/mod/mod_rewrite.html
我的猜测是
RewriteBase /midas
(在RewriteEngine
之后)