【问题标题】:WHMCS URL-friendly Custom created page with htaccessWHMCS URL-friendly 使用 htaccess 自定义创建的页面
【发布时间】:2021-10-18 13:58:11
【问题描述】:

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

【问题讨论】:

  • 你的实际问题是什么?
  • 如何加载不带 .php 扩展名的 WHMCS 自定义页面,或如何为 htaccess 上的特定页面定义规则以在不带 .php 扩展名的情况下加载。
  • 好的,那么请将您当前的实现添加到问题中,以便对其进行检查。
  • 代码与提供的默认链接相同,无需将其添加到问题中。但是,我最终为 htaccess 文件中的所有自定义页面设置了特定规则,如下所示: RewriteRule ^customPage$ customPage.php [L]

标签: .htaccess whmcs


【解决方案1】:

最终在 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 2014-12-29
    • 1970-01-01
    • 2016-07-28
    • 1970-01-01
    相关资源
    最近更新 更多