У меня возникла проблема с настройкой локальной тестовой среды с использованием codeigniter и уже существующего кода.codeigniter on xampp хочет, чтобы я использовал index.php в uri
Ну, проблема в том, что я не могу открыть страницу, не имея «index.php» в моем URL-адресе. Итак, «test.mydomain.local/index.php/search» отлично работает, а «test.mydomain.local/search» - нет. Но все ссылки в коде, исключая URL-адреса действий в тегах форм, не имеют этого «index.php» в URL-адресе.
Как я могу решить проблему, чтобы codeigniter или xampp нуждались в этом «index.php» в URL? Нужно ли мне что-то менять в своем коде или, возможно, в .htaccess?
Вот мой config.php
$config['base_url'] = "http://test.mydomain.local/";
$config['index_page'] = "index.php";
$config['uri_protocol'] = "AUTO";
Ну, этот код заставляет "index.php" в остросюжетном URL в виде тегов. Но на самом деле я не хочу иметь этот index.php в любом URL-адресе. Так что мой config.php должен выглядеть так, я думаю:
$config['base_url'] = "http://test.mydomain.local/";
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
Вот .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
### force www
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule (.*) h t t p :// w w w . m y d o m a i n . c o m/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain.local [NC]
RewriteRule (.*) h t t p :// t e s t . d o m a i n . l o c a l/$1 [R=301,L]
### if the is not a request for an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
### and the URI does not end with a/
RewriteCond %{REQUEST_URI} !^([^?]*)/($|\?)
### redirect and add the slash.
RewriteRule ^([^?]*) $1/ [L,R=301]
### if the is not a request for an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite to index.php passing the URI as a path, QSA will preserve the existing query string
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</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>
Может кто-нибудь мне помочь? Это сводит меня с ума!
есть много вопросов и ответить, как этот problem.You может посмотреть документацию https://ellislab.com/codeigniter/user -руководство/общее/urls.html –