apache - 如何向 WHMCS 添加一些 url 重写?
问题描述
我正在尝试为 url 重写设置一个经典的 .htaccess 文件。
目前我正试图简单地重写login.php
为login
我尝试使用以下 .htacess 文件:
RewriteEngine on
RewriteBase /
# Not Directory
RewriteCond %{REQUEST_FILENAME} !-d
# Not file
RewriteCond %{REQUEST_FILENAME} !-f
# Not Link ?? No Need.
#RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^login/$ login.php [L]
当我尝试访问时,这给了我以下信息http://MYIP/login
http://MYIP/https://MYIP/login/
我还尝试使用以下内容:
### BEGIN - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ###
<IfModule mod_rewrite.c>
RewriteEngine on
# RewriteBase is set to "/" so rules do not need updating if the
# installation directory is relocated. It is imperative that
# there is also a RewriteCond rule later that can effectively get
# the actual value by comparison against the request URI.
#
# If there are _any_ other RewriteBase directives in this file,
# the last entry will take precedence!
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 ###
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]
RewriteRule ^/login/$ ^/login.php$ [L]
我得到了同样的结果。
在 WHMCS 的管理面板下,我将 url 重写设置为 Basic URLs。
在私人导航中打开我有错误 404。
解决方案
经过@RavinderSingh13 的一些搜索和帮助后,我开始了以下工作.htaccess
:
### BEGIN - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ###
<IfModule mod_rewrite.c>
RewriteEngine on
# RewriteBase is set to "/" so rules do not need updating if the
# installation directory is relocated. It is imperative that
# there is also a RewriteCond rule later that can effectively get
# the actual value by comparison against the request URI.
#
# If there are _any_ other RewriteBase directives in this file,
# the last entry will take precedence!
RewriteBase /
# Redirect directories to an address with slash
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#Change
RewriteRule ^login$ ./login.php [L,NC]
# 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 ###
推荐阅读
- mongodb - MongoDB:副本集和循环查询分布?
- sql - 使用 PostgreSQL \COPY
- python - 将表拆分为多个数据框
- java - 当我使用 Camera2Api 拍照时,Android 图像被旋转
- mongodb - Docker 上的 MongoDB 错误:将集合 config.transactions 标记为集合版本:
- spring-boot - 使用 WebClient 设置超时
- javascript - 在 HTML 中动态添加 js 脚本标记元素 - 幕后发生了什么?
- c# - 使用实体框架的外键问题
- javascript - Antd 选择搜索框不渲染匹配项
- ms-access - Ms-Access 2016 在 DAO.Recordset OpenRecordset(