2013-11-15 4 views
1

Ниже показан код .htaccess для генерации SEF-url, когда joomla SEF включен в бэкэнд..htaccess перенаправление index.php

## Begin - Joomla! core SEF Section. 
# 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
# 
# If the requested path and file is not /index.php and the request 
# has not already been internally rewritten to the index.php script 
RewriteCond %{REQUEST_URI} !^/index\.php 
# and the request is for something within the component folder, 
# or for the site root, or for an extensionless URL, or the 
# requested URL ends with one of the listed extensions 
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC] 
# and the requested path and file doesn't directly match a physical file 
RewriteCond %{REQUEST_FILENAME} !-f 
# and the requested path and file doesn't directly match a physical folder 
RewriteCond %{REQUEST_FILENAME} !-d 
# internally rewrite the request to the index.php script 
RewriteRule .* index.php [L] 

У меня есть простая проблема, с которой я не могу окунуться. Я положил это условие так, чтобы, если URL-адрес domain.com/index.php, он должен перейти на домен.com, и это должно произойти только в том случае, если шаблон совпадает именно с index.php. Однако это происходит для всех URL-адресов.

RewriteCond %{THE_REQUEST} [^.]*|/(index.php)$ 
RewriteRule ^index.php$/[R=301,L] 

ответ

0

it should go to domain.com and this should happen only if the pattern matches exactly as index.php. However this happens for all urls.

Это происходит из-за неправильные регулярные выражения, который вы используете. Используйте это правило, чтобы удалить index.php из URIs:

RewriteCond %{REQUEST_URI} !/administrator [NC] 
RewriteCond %{THE_REQUEST} /index\.php [NC] 
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE] 
+0

вы можете сказать мне, почему вы не использовали $ в конце RewriteCond, поскольку $ означает конец строки, не так ли? –

+0

Спасибо за это. В основном он делает то, что я хочу сделать. Однако это также влияет на папку администратора joomla и не позволяет мне войти в систему. Сохраняет перенаправление на экран входа в систему. Могу ли я как-то предотвратить это. –

+0

да, это можно сделать, см. Править выше. – anubhava

Смежные вопросы