具体 url 使用和不使用 .php 使用 .htaccess
Specific url to work with and without .php using .htaccess
我正在尝试配置特定的 url 以使用和不使用 .php
扩展。
例如想通过以下两种方式访问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/*(.*) / [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?/ [L,QSA]
# RewriteRule ^(.*)$ /index.php/ [L]
</IfModule>
您可以在重定向规则下方插入一个重写规则:
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/library/.* [NC]
RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]
# add .php extension to specific URIs
RewriteRule ^(manage)/?$ .php [L,NC]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/ [L,QSA]
我正在尝试配置特定的 url 以使用和不使用 .php
扩展。
例如想通过以下两种方式访问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/*(.*) / [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?/ [L,QSA]
# RewriteRule ^(.*)$ /index.php/ [L]
</IfModule>
您可以在重定向规则下方插入一个重写规则:
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/library/.* [NC]
RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]
# add .php extension to specific URIs
RewriteRule ^(manage)/?$ .php [L,NC]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/ [L,QSA]