2012-03-01 6 views
1

установить CodeIgniter и начать писать код на it.First я хочу, чтобы удалить index.php и сделать некоторые исследования о it.I удалить его с небольшим кодом HTAccess ниже,Codeigniter Htaccess и base_url

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

, а затем установить мой base_url в config.php, как,

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

, а затем я решил использовать base_url в действиях форме в

и написал это так (пожалуйста, смотрите на действия)

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

, но он не работает

и печатает URL-адрес, как этот
enter image description here

то, что я сделал все это не работает

и я подозреваю, что из моего HTAccess file.i удалили , Я использую его для удаления index.php в codeigniter по умолчанию.

и установить свой новый базовый 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 Framework сети:

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

Для веб CodeIgniter:

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

+0

добавлен еще один пример в моем ответе, по-прежнему не идти? –

+0

К сожалению, да: с –

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 –

0

Для удаления index.php с url вы можете попробовать следующее.

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