首页 > 解决方案 > WHMCS URL-friendly 使用 htaccess 自定义创建的页面

问题描述

我需要加载没有 .php 扩展名的 WHMCS自定义页面,但它返回 404。URL 友好规则在 htaccess 上设置为默认值。但它们仅适用于基本页面。最后一个解决方案是在 htaccess 上设置自定义规则,以便在没有 .php 扩展名的情况下加载特定 URL。

标签: .htaccesswhmcs

解决方案


最终在 htaccess 上为每个自定义页面设置自定义规则,以便在没有 .php 扩展名的情况下也加载。

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteBase /

#rempove .php for custom pages on by one
RewriteRule ^customPageOne$ customPageOne.php [L]
RewriteRule ^customPageTwo$ customPageTwo.php [L]
RewriteRule ^customPageThree$ customPageThree.php [L]

# 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>

推荐阅读