我是一个asp.net的人,这是我第一次处理PHP.
无论如何,我一直在努力将现有网站迁移到新服务器.
此站点使用codeigniter.
当我调用http:// mydomain/admin时 出现404错误!
但如果我打电话:
HTTP://mydomain/index.php/admin
有用!
我在根上放了一个.htaccess文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)
我在config.php中设置了:
$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)
我的routes.php:
$route['default_controller'] = 'welcome';
$route['scaffolding_trigger'] = '';
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它不起作用.我想它一定是非常简单的东西......
谢谢!
你有没有看过这个?:http: //codeigniter.com/wiki/mod_rewrite/
如果没有,试试这个:
<IfModule mod_rewrite.c>
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]
</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>
Run Code Online (Sandbox Code Playgroud)
曾经有一个来自Jamie Rumbelow我常常使用它,但它不再在他的博客上了......我现在已经习惯了nginx,所以我最喜欢的配置对你不起作用.