English 中文(简体)
密码检索——在子里的控制器不工作
原标题:Codeigniter htaccess - controllers in subfolder not working

我对 CI来说是新鲜事,对改写规则不知很多。 我从中途站找到了上门通道规则,使我能够从URL中删除指数.php。 限制使用的规则如下:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /siebeluigen/

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

但是,如果我把我的控制人员直接带在控制人员内部,那就没有工作了。 例如

如果我把我的申请控制人带走,我会把他带走。

application/controllers/application.php

然后,我可以从URL那里查阅。

http://localhost/siebeluigen/application

但是,如果我的名录结构是这样的话。

application/controllers/app/application.php

接着,我发现有ur的错误。

http://localhost/siebeluigen/app/application

but it works like this

http://localhost/siebeluigen/index.php/app/application

因此,我很相信,我应该能够作出改变,使之发挥作用。

请帮助!

<>Update>

My htaccess file was in the application folder instead of root. Moving the file to the folder were index.php is located solved the issue. I have marked the answer that is working. Thanks...

最佳回答

这是我在我所有的项目中使用的单线文件:

Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>

    # activate URL rewriting
    RewriteEngine on

    # do not rewrite links to the documentation, assets and public files
    RewriteCond $1 !^(images|assets|uploads|captcha)

    # do not rewrite for php files in the document root, robots.txt or the maintenance page
    RewriteCond $1 !^([^..]+.php|robots.txt)

    # but rewrite everything else
    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.

    ErrorDocument 404 index.php

</IfModule>  

Then - also make sure that inside your config.php file

  $config[ index_page ] =   ;

edit:You NEVER 想向您的申请文件夹点人——你ALWAYS将其贴在你的索引上。 php-EVERYTHING通过指数.php,而且它确实在需要时转行。

问题回答

这通常是为了转而适用。 php

RewriteCond %{REQUEST_URI} ^application.* 

参照/申请与这一条件相符。 修改:

RewriteCond %{REQUEST_URI} ^app/application.* 




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签