[编辑]:重复如何在 codeigniter 的路径中删除“index.php”
[那里的解决方案对我不起作用]
我第一次尝试 codeigniter,我对 php 还是很陌生。我想从我的网址中删除 index.php。
安装的代码点火
器用我自己的替换了 index.php
我的 .htaccess 中有这个
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#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>
我的重写肯定是打开的,我在我的根目录中加载了一个 phpinfo 页面,它显示了加载的模块。我还检查了 httpd.conf
当我从 NetBeans 运行时,我被定向到 localhost:8888/domain/index.php 并且
当我转到 localhost:8888/domain 时我的索引页面加载然后我的 index.php 也加载
当我去 localhost:8888/domain/welcome 或 localhost:8888/domain/welcome.php 我得到 404
The requested URL /index.php/welcome was not found on this server.
当我去 localhost:8888/domain/index.php/welcome 我被定向到欢迎控制器但它只是加载我的 index.php 但没有标记。
我也在 .htaccess 中试过这个:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
我得到:
这也不起作用(我知道,他们都打算做几乎相同的事情):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,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>
我在 config/config.php 中有:
$config['base_url'] = 'localhost:8888/domain.com/';
$config['index_page'] = '';