2011-04-11 68 views
0

我有这样的site,当你点击在中心去,我把它去这个网址取出的index.php不工作

http://dev.posnation.com/welcome/redirect 

这是不是欢迎控制器和正确的页面重定向操作。正确的URL是

http://dev.posnation.com/index.php/welcome/redirect 

我笨结构是这样的

[email protected] 1 tamer staff 225 Apr 11 13:09 .htaccess 
[email protected] 18 tamer staff 612 Apr 8 17:26 application 
drwxr-xr-x 11 tamer staff 374 Apr 11 09:46 css 
[email protected] 6 tamer staff 204 Mar 24 14:20 graphics 
drwxr-xr-x 17 tamer staff 578 Apr 11 09:54 js 
[email protected] 10 tamer staff 340 Apr 7 12:20 system 
[email protected] 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 

任何想法

回答

1

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)。

有足够多的问题也可能是在http://codeigniter.com/wiki/mod_rewrite/

+0

虽然这会产生site.com/index.php/controller/method吗? – Cogicero 2011-04-11 17:31:33

+0

没有工作......也许它有一些与我的index.php和我的系统和应用程序文件夹生活 – Trace 2011-04-11 17:31:54

+0

这主要是重定向到URI的index.php页面,请确保您设置为AUTO在您的路线和从配置文件中的base_url中删除'index.php',你的系统目录是服务器端,这应该没有任何作用。 – RobertPitt 2011-04-11 17:33:17

2

你错过了之后的RewriteCond一个重写规则行。尝试

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] 
+0

仍然没有。可能它与我的index.php和我的系统和应用程序文件夹的位置有关 – Trace 2011-04-11 17:33:07

+0

你说你的index.php出了一个目录?什么是目录的名称,或者你能说明你的意思? – Cogicero 2011-04-11 17:36:24

+0

你有没有从配置文件base_url中删除index.php? – Cogicero 2011-04-11 17:39:22

0

它有时会混淆什么会起作用。尝试添加此作为最后一行

RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 
0

我有类似的问题。确保你得到了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吗?。这对我造成了问题。

相关问题