我在“mydomain.com”上运行一个 WordPress 站点,并在 mydomain.com/portal 上安装了 whmcs。一切都很好。我最近摆脱了 WordPress 安装并在 mydomain.com 上建立了一个 Django 网站。 mydomain.com/portal 上的 WHMCS 安装仍然存在。
但问题是:
如果我访问 mydomain.com/portal/index.php 或 mydomain.com/portal/login,页面就会加载
我当前在 mydomain.com 中的 .htaccess 文件:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/user/mydomain.com"
PassengerBaseURI "/"
PassengerPython "/home/usr/virtualenv/mydomain.com/3.9/bin/python"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END
# Newly added text below here, in order to troubleshoot CSS not showing up
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^static/(.*)$ /home/usr/mydomain.com/staticfiles/$1 [QSA,L,NC]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^media/(.*)$ /home/usr/mydomain.com/blog_images/$1 [QSA,L,NC]
</IfModule>
<FilesMatch "\.(?i:ico|flv|jpg|jpeg|png|gif|js|css)$">
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
</IfModule>
FileETag MTime Size
</FilesMatch>
我尝试添加以下内容,但没有帮助。
重写引擎开启 RewriteCond %{REQUEST_URI} !^/portal/ RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] 标头始终设置 Content-Security-Policy“upgrade-insecure-requests;”
我正在尝试让 whmcs 安装像以前在 mydomain.com/portal 上一样加载,而不必链接到 index.php
您已从 WordPress 网站转换为 Django 网站,.htaccess 规则可能需要进行一些调整以适应新设置。 这是 .htaccess 文件的修订版本,它应该正确地将请求定向到 WHMCS 安装:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
# Redirect requests to WHMCS installation
RewriteRule ^portal(/.*)?$ /portal/index.php [L]
# Your existing rules below
Header always set Content-Security-Policy "upgrade-insecure-requests;"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/user/mydomain.com"
PassengerBaseURI "/"
PassengerPython "/home/usr/virtualenv/mydomain.com/3.9/bin/python"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END
# Newly added text below here, in order to troubleshoot CSS not showing up
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^static/(.*)$ /home/usr/mydomain.com/staticfiles/$1 [QSA,L,NC]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^media/(.*)$ /home/usr/mydomain.com/blog_images/$1 [QSA,L,NC]
</IfModule>
<FilesMatch "\.(?i:ico|flv|jpg|jpeg|png|gif|js|css)$">
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
</IfModule>
FileETag MTime Size
</FilesMatch>
“RewriteRule ^portal(/.*)?$ /portal/index.php [L]”应该将所有到 /portal 的请求重定向到 /portal/index.php,允许 WHMCS 在内部处理路由以前做过。