如何解决如何在 .htaccess 重定向然后重写
好的,我是新手……第一次在这里提问。 我有一个名为 example.com 的域 我所有的网站都位于以下 URL:https://example.com/example.com/inter/pf2/ 我想要的是以下内容: 当用户转到 https://example.com 时显示 https://example.com/example.com/inter/pf2/ 处的所有内容但 URL 一直显示 example.com 我尝试了以下方法:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^$ /example.com/inter/pf2/ [L]
但它不起作用
编辑:
This is the .htaccess:
RewriteEngine on
# php -- BEGIN cPanel-generated handler,do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler,do not edit
RewriteRule ^/?$ %{HTTP_HOST}/inter/pf2/ [L]
解决方法
根据您展示的样品,您可以尝试以下操作吗?请先清除浏览器缓存,然后再测试您的网址。
RewriteEngine ON
RewriteCond %{REQUEST_URI} !^/example\.com/inter/pf2 [NC]
RewriteRule ^(.*)/?$ %{HTTP_HOST}/inter/pf2/$1 [L]
,
这一行:
RewriteCond %{HTTPS} !=on
表示“如果 HTTPS 未开启”。换句话说,“只有在通过普通的“http://”连接时才运行规则。
但是您的示例显示您尝试访问“https://”网址。
您可能只是不需要那个条件,但如果您想说“如果 HTTPS is 已打开”,则需要 =
而不是 !=
:
RewriteCond %{HTTPS} =on
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。