проблема переписывания модов в codeigniter - PullRequest
1 голос
/ 13 октября 2009

Я занимаюсь разработкой сайта на своем локальном хосте (приложение Usbwebserver). Я использую CodeIgniter Framework:

URL-адрес "http://localhost/daniel/index.php"

со следующими параметрами:

конфиг / маршруты:

$route['default_controller'] = "site";

конфиг / конфигурация:

$config['base_url'] = "http://localhost/daniel";
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";

Я пробовал следующий код .htaccess:

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]

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

# Если у нас не установлен mod_rewrite, все 404 # можно отправить в index.php, и все работает как обычно. # Представлено: ElliotHaughin

ErrorDocument 404 /index.php

Я хочу удалить index.php и загрузить свой контроллер по умолчанию с http://localhost/daniel.

Есть предложения?

Ответы [ 2 ]

1 голос
/ 14 октября 2009

Я использовал hataccess из codigniter wiki (тот же, что был у меня выше):

RewriteEngine On RewriteBase /

# Removes the "/" at the end
RewriteRule (.+)/$ /$1 [L,R]

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ daniel/index.php?/$1 [L]

# Если у нас не установлен mod_rewrite, все 404 # можно отправить в index.php, и все работает как обычно. # Представлено: ElliotHaughin

ErrorDocument 404 /index.php

При все той же опции, только $ config ['uri_protocol'] = "AUTO" (вместо URI_PROTOCOL) и как-то начали работать (и у меня есть папка для приложений вне системной папки )

Спасибо всем, кто любезно ответил мне!

1 голос
/ 13 октября 2009

Попробуйте:

RewriteRule ^(.*)$ /daniel/index.php?/$1 [L]
...