mod_rewrite путь информации постфикс и per-dir prrefix

968
Alexey Kosov

Существует проблема с конфигурацией .htaccess.

Мне просто нужно, чтобы URL / категория соответствовал сценарию category.php, но когда я пытаюсь открыть этот URL, вместо этого появляется ошибка 404.

Вот мой .htaccess:

RewriteEngine on RewriteRule ^category/ category.php [QSA,L] 

журнал htaccess:

init rewrite engine with requested uri /category/ [www.test.com/sid#7fc1c2694dd0][rid#7fc1c25f00a0/initial] pass through /category/ [www.test.com/sid#7fc1c2694dd0][rid#7fc1c25e80a0/subreq] [perdir /home/ubuntu/domains/test.com/public_html/] add path info postfix: /home/ubuntu/domains/test.com/public_html/category.php -> /home/ubuntu/domains/test.com/public_html/category.php/ [www.test.com/sid#7fc1c2694dd0][rid#7fc1c25e80a0/subreq] [perdir /home/ubuntu/domains/test.com/public_html/] strip per-dir prefix: /home/ubuntu/domains/test.com/public_html/category.php/ -> category.php/ [www.test.com/sid#7fc1c2694dd0][rid#7fc1c25e80a0/subreq] [perdir /home/ubuntu/domains/test.com/public_html/] applying pattern '^category/' to uri 'category.php/' [www.test.com/sid#7fc1c2694dd0][rid#7fc1c25e80a0/subreq] [perdir /home/ubuntu/domains/test.com/public_html/] pass through /home/ubuntu/domains/test.com/public_html/category.php 

И в результате ошибка 404 Apache: не найден

Запрашиваемый URL / категория / не найден на этом сервере.

Если я открываю /category.php напрямую, это работает.

Вот конфиг vhost:

<VirtualHost *:80> ServerName test.com ServerAlias www.test.com  ServerRoot /home/ubuntu/domains/test.com DocumentRoot public_html <Directory "/home/ubuntu/domains"> Options FollowSymLinks MultiViews AllowOverride all Require all granted </Directory>  RewriteEngine On LogLevel alert rewrite:trace3  ErrorLog logs/error.log CustomLog logs/access.log combined  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json DeflateCompressionLevel 9 </VirtualHost> 

Версия сервера: Apache / 2.4.7 (Ubuntu)

Построен сервер: 22 июля 2014 14:36:38

1

1 ответ на вопрос

1
knb

У меня была похожая проблема и заменили

Options MultiViews 

с

Options -MultiViews 

На самом деле я закончил с

Options +Indexes +FollowSymLinks -MultiViews 

Я нашел это решение здесь:

https://velenux.wordpress.com/2012/07/17/apache-mod_rewrite-multiple-add-path-info-postfix/