[英]Removing the index.php is not working
我有这个网站 ,当您单击中心的去时,我会转到该URL
http://dev.posnation.com/welcome/redirect
这不是欢迎控制器和重定向操作的正确页面。 正确的网址是
http://dev.posnation.com/index.php/welcome/redirect
我的codeigniter结构是这样的
-rw-r--r--@ 1 tamer staff 225 Apr 11 13:09 .htaccess
drwxr-xr-x@ 18 tamer staff 612 Apr 8 17:26 application
drwxr-xr-x 11 tamer staff 374 Apr 11 09:46 css
drwxr-xr-x@ 6 tamer staff 204 Mar 24 14:20 graphics
drwxr-xr-x 17 tamer staff 578 Apr 11 09:54 js
drwxr-xr-x@ 10 tamer staff 340 Apr 7 12:20 system
drwxr-xr-x@ 16 tamer staff 544 Apr 7 12:20 user_guide
与index.php出一个目录
我的.htaccess包含以下内容
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
有任何想法吗
您在RewriteCond之后错过了一个Rewrite规则行。 尝试
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Codeigniter Wiki提供以下功能:
<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>
在您的配置中,请相应地更改以下变量:
config['uri_protocol'] = 'QUERY_STRING'; //set to QUERY_STRING
和
$config['index_page'] = ""; //Remove index.php
确保已加载Apache mod_rewrite模块(仅在上面抛出404时)。
我有一个类似的问题。 确保正确获得RewriteRule。 不同的方法还需要使用不同的方式来捕获变量。 我看到了两种情况,其中一种基本上是将$ _GET数组变量应用于示例中给出的url变量。
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
RewriteRule ^(.*)$ ./index.php?url=$1 [L,QSA]
您可以分别捕获'm个:
echo $_SERVER['PATH_INFO'];
echo $_GET['url'];
CodeIgniter使用index.php?/ $ 1。 这给我带来了麻烦。
有时会混淆什么会起作用。 尝试将其添加为最后一行
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.