2016-11-22 75 views
1

我试图配置一个特定的URL与.php扩展名一起使用。具体的URL使用和不使用.php使用.htaccess

例如要访问两种方式以下链接:

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]