2012-03-01 92 views
1

我安装笨,并开始写it.First一些代码,我想删除的index.php,并就它。我的一些研究与下方的小htaccess的代码中删除它,笨htaccess以及BASE_URL

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|css|robots\.txt) 
RewriteRule ^(.*)$ /pasaj/index.php/$1 [L] 

然后将我在config.php作为BASE_URL,

$config['base_url'] = 'http://localhost/pasaj/'; 

,然后我决定在形式上的行动

使用BASE_URL和写的一样,(请看动作)

<form method="post" id="formSubmit" name="fSubmit" action=<?php base_url(); ?>"kayit/kayitOnay/"> 

,但它没有工作

并打印网址像
enter image description here

,我所做的一切都没有工作

,我从我的htaccess怀疑file.I删除它。我使用它在codeigniter默认中删除index.php。

,并设置我的新 基本URL一样,一定

http://localhost/pasaj/index.php/ 

,但不改变上述表单代码

任何东西,它的工作原理。

现在,我想仍然使用这个htaccess文件来删除index.php,但是当htaccess文件存在时,我的base_url工作不正常。什么可能是htaccess文件的变化?

回答

2

尝试在本地服务器上此

RewriteEngine on 
RewriteBase /pasaj/ 
RewriteCond $1 !^(index\.php|images|css|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 

我的htaccess的文件看起来是这样的:

对于Zend框架网页:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

对于笨网:

RewriteEngine on 
RewriteBase /pasaj/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L] 
+0

仍然像打印以http://本地主机/ pasaj/kayit/kayit/kayitOnay/ – 2012-03-01 08:29:05

+0

加入我的答案,仍然没有去另一个例子吗? – 2012-03-01 08:32:43

+0

不幸的是:s – 2012-03-01 08:36:37

0

T他是我的标准htaccess文件。

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

您可能需要更改重写基准。

+0

不适用于我:S – 2012-03-01 15:49:44

0

要从url中删除index.php,您可以尝试以下操作。

Open config.php from system/application/config directory and replace 
$config['index_page'] = “index.php” by $config['index_page'] = “” 

Create a “.htaccess” file in the root of CodeIgniter directory and add the following lines. 

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

In some case the default setting for uri_protocol does not work properly. To solve this problem just replace 
$config['uri_protocol'] = “AUTO” by $config['uri_protocol'] = “REQUEST_URI” from system/application/config/config.php 
+0

如果可能的话,你能解释一下这个链接吗... RewriteRule ^(。*)$ index.php/$ 1 [L,QSA] – pratik 2012-10-12 12:10:20