CodeIgniter: невозможно удалить index.php из URL - PullRequest
1 голос
/ 26 ноября 2011

Не повезло, удалив файл index.php из URL.

Например, я хочу получить доступ к контроллеру приветствия через http://domain.com/welcome

В настоящее время при попытке тоже появляется ошибка 404.

Однако на данный момент я могу получить доступ только через http://domain.com/index.php/welcome

У меня есть это в настоящее время в моем файле .htaccess, который я получил из руководства пользователя CI:

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

У меня есть файл .htaccess, расположенный в каталоге над папкой приложения.

directory screenshot

Любая помощь будет отличной.

1 Ответ

0 голосов
/ 26 ноября 2011

У меня есть следующий .htaccess

<IfModule mod_rewrite.c>
    AcceptPathInfo On

    RewriteEngine On

    ### Canonicalize codeigniter URLs

    # If your default controller is something other than
    # "welcome" you should probably change this
    # RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
    # RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

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

</IfModule>

<IfModule !mod_rewrite.c>

    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php

</IfModule>

Также, пожалуйста, убедитесь, что директива AllowOverride вашего httpd.conf не установлена ​​в None, так как это предотвратит чтение ваших правил .htaccess.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...