2016-11-22 1 views
1

Я пытаюсь настроить конкретный URL-адрес для работы с и без расширения .php.Конкретный URL-адрес для работы с .php и без него .htaccess

Например хотите получить доступ к URL ниже обоими способами:

example.com/manage.php 

example.com/manage 

Вот мой текущий .htaccess:

<IfModule mod_rewrite.c> 
     RewriteEngine On 
     RewriteBase/

     # Removes index.php from ExpressionEngine URLs 
     RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] 
     RewriteCond %{REQUEST_URI} !/library/.* [NC] 
     RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] 

     # Directs all EE web requests through the site index file 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule ^(.*)$ /index.php?/$1 [L,QSA] 
     # RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

ответ

2

Вы можете вставить правило перезаписи чуть ниже правила переадресации:

RewriteEngine On 
RewriteBase/

# Removes index.php from ExpressionEngine URLs 
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] 
RewriteCond %{REQUEST_URI} !/library/.* [NC] 
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] 

# add .php extension to specific URIs 
RewriteRule ^(manage)/?$ $1.php [L,NC] 

# Directs all EE web requests through the site index file 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA] 
Смежные вопросы