Php 找不到CodeIgniter URL

Php 找不到CodeIgniter URL,php,.htaccess,codeigniter,url-rewriting,Php,.htaccess,Codeigniter,Url Rewriting,在此处输入代码我在.htaccess文件中获得了此代码: RewriteEngine On RewriteBase /projFolder ### Canonicalize codeigniter URLs # If your default controller is something other than # "welcome" you should probably change this RewriteRule ^(mycontrol(/index)?|index(\.php)?)

在此处输入代码
我在.htaccess文件中获得了此代码:

RewriteEngine On
RewriteBase /projFolder

### Canonicalize codeigniter URLs

# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(mycontrol(/index)?|index(\.php)?)/?$ /  [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

# Enforce www
# If you have subdomains, you can add them to 
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]

# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]

###

# 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]

# 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]
我的项目位于/var/www/projFolder->该文件夹中的结构是

/application
/system
/user_guide
.htaccess
index.php
我更改了$route['default_controller']=“mycontrol”;在config routes.php文件中。
如果我键入url localhost/projFolder/it,则从该控制器加载默认mycontrol.php控制器和索引函数。如果我转到localhost/projFolder/myFunction->这意味着我想从默认控制器加载myFunction,它会给我“在该服务器上找不到请求的URL”。有人能帮忙吗?谢谢。

虽然
mycontrol
是默认的控制器,但它不会工作,因为当您键入
localhost/projFolder/myFunction
时,它希望找到名为
myFunction
控制器。如果要访问
myfunction
,请尝试键入
localhost/projFolder/mycontrol/myfunction
。使用这种方法,您将调用控制器并请求特定的函数

打开您的
config/routes.php
文件

添加此行:

$route['mycontrol/(:any)'] = "mycontrol/index";
然后我从来没有使用过这么大的
.htaccess
和codeigniter,我总是使用这个,它工作得很好:

RewriteEngine On
RewriteBase /projFolder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /projFolder/index.php/$1 [L]
要删除index.php,必须使用htaccess并在
config/config.php
中进行更改:

$config['index_page']='';

将您的.htaccess文件编辑为:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。*index.php/$0[PT,L]

问题在于,我必须编写localhost/projFolder/index.php/来从控制器加载控制器和函数。我想从url中删除index.php,使其与localhost/projFolder类似/mycontrol@LachezarRaychev好的,现在检查我的答案是否已更新,您在重新写入URL时遇到问题,因此可能是htaccess或配置文件,您是否尝试了我的htaccess?是的。。。可悲的是,它不起作用:(5个小时在这条船上)already@LachezarRaychev但请用谷歌搜索一下如何从codeigniter的url中删除index.php,并在这里报告错误。我把它放在虚拟主机上,它和官方的codeigniter.htaccess配合得很好