Прежде всего, я попробовал предложение, указанный здесь:Codeigniter URL переписать, чтобы удалить index.php
- CodeIgniter removing index.php not working
- codeignitor: Remove index.php not working
- CodeIgniter .htaccess index.php rewrite not working on user directory
- How to remove "index.php" in codeigniter's path
- https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html
- Rewriterule for CodeIgniter not working
Я пытаюсь удалить пресловутый index.php
в адресной строке.
Это моя текущая конфигурация:
В моем /etc/apache2/sites-available/my.website.com.conf файл я положил это:
<Directory /path/to/root/directory/>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
В моей файл /etc/apache2/apache2.conf файл, я поставил это:
<Directory /path/to/root>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
В моем CodeIgniter корневой каталог (то же самое дир с index.php), у меня есть файл .htaccess, как это:
<IfModule mod_rewrite>
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>
И, наконец, мое приложение/Config/config.php:
$config['base_url'] = 'http://my.website.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Когда я протестировал вышеуказанную конфигурацию на своем локальном ПК (работает Ubuntu 14.04), он работает нормально. Однако, когда я пытаюсь реплицировать конфигурацию на моем сервере (работает Ubuntu 14.04), как-то это не работает.
Делать это:
- http://my.website.com/ < < показывает по умолчанию Codeigniter страница приветствия
http://my.website.com/controller_name/ < < передачи:
Не Обнаружили Запрошенный URL/Логин не был найден на этом сервере , Apache/2.4.7 (Ubuntu) сервер на my.website.com Порт 80
< < http://my.website.com/index.php/controller_name показывает страницу, однако URL для статических файлов (например, JS/CSS/изображения) не правильно неправдоподобным, так как печать это:
<link rel="stylesheet" href="assets/styles/material-design-icons.css" type="text/css" /> <link rel="stylesheet" href="assets/styles/font.css" type="text/css" /> <link rel="stylesheet" href="assets/styles/app.css" type="text/css" />
бы добавить index.php, когда видно из исходного кода инспектора.
Я что-то пропустил? Может ли кто-нибудь указать мне в правильном направлении?
Спасибо.
EDIT # 1 Ниже моя структура папок
EDIT # 2 я могу подтвердить, что mod_rewrite включен
http://stackoverflow.com/questions/31742035/codeigniter-routes-is-not-working/31742564#31742564 – shafiq