我目前正在尝试从WHMCS安装中删除.php扩展名。我的.htaccess当前看起来像这样,并完成了工作:
# Ignore admin/manage directory
RewriteRule ^(manage|admin)($|/) - [L]
## BEGIN Strip PHP Extension from URLs ##
Options +FollowSymLinks +MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
## END Strip PHP from URLs ##
### BEGIN - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ###
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Redirect directories to an address with slash
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]
# Send all remaining (routable paths) through index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Determine and use the actual base
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ %2index.php [QSA,L]
</IfModule>
### END - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ###
# Force SSL
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
但是,我遇到了与/ knowledgebase之类的特定页面有关的问题,在正常的WHMCS安装中,该页面始终不使用.php扩展名。知识库页面已加载,但是单击文章可将URL更改为以下示例
/knowledgebase/2/Do-you-keep-backups.html
问题在于页面实际上并未更改,并且继续显示文章列表,就好像我只是在/ knowledgebase上一样。因此,我试图从去除.php扩展名的.htaccess重写规则中忽略该路径(例如/ download等)。
我尝试使用RewriteCond %{REQUEST_URI} !^(.*/)?knowledgebase\.php$ [NC]
和RewriteCond %{REQUEST_URI} !^(.*/)?knowledgebase$ [NC]
无济于事。