2012-03-01 82 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