截至目前......这是我运行应用程序时显示的地址(并且功能正常)。
http://localhost:8888/baseline/index.php
如果我带走了index.php它也有效......
http://localhost:8888/baseline/
运行这两个URI与运行此函数(功能正常)相同。
http://localhost:8888/baseline/index.php/RegisterController/index
但是,如果我尝试在没有index.php的情况下运行它,它就不起作用......
http://localhost:8888/baseline/RegisterController/index
在我的代码中,我有2个.htaccess文件......
在“视图”正下方的那个代码就是这个......
Deny from all
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
在“系统”下面的一个代码就是这个......
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
# my url is http://localhost/arny
#RewriteBase /arny/
# set your own
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>
这就是我的配置文件的样子......
我已经尝试将它从'AUTO'设置为'PATH_INFO'并且没有任何运气。 有一些关于改变Apache的事情的讨论,但我不知道如何做到这一点。
我已经检查了以下帖子,但无法正常工作......
我现在正在跑...
绝对让我知道我可以提供的其他信息,我会重新编辑帖子。在浏览了其他文档之后,我肯定觉得自己像个白痴,但仍然无法理解这一点。
答案 0 :(得分:1)
我也一直在玩它。这是适合我的那个,我害怕触摸它:;)j / k
RewriteEngine On
RewriteRule ^(resources)/(.*) $1/$2 [L]
RewriteRule ^(user_guide)/(.*) $1/$2 [L]
RewriteRule (.*) index.php?$1 [L]
它位于application / system / user_guide目录之外。资源是我自己的公共文件夹,忽略该行。
我没有触及内部的.htaccess文件。他们就是这样:
Deny from all
希望这会有所帮助:)
编辑:同时检查你是否启用了mod_rewrite ..
答案 1 :(得分:0)
尝试在系统文件夹下使用此功能。这将允许您需要传递的扩展。 (样式表,脚本等......)
RewriteEngine On
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]