如何在 .htaccess 重定向然后重写

nan*_*iac 1 apache .htaccess mod-rewrite friendly-url url-rewriting

好吧,我是新手……第一次在这里提问。我有一个名为example.com的域, 我所有的网站都位于以下 URL:https : //example.com/example.com/inter/pf2/ 我想要的是以下内容:当用户转到https://example 时.comhttps://example.com/example.com/inter/pf2/显示所有内容,但 URL 一直说example.com 我尝试了以下操作:

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^$ /example.com/inter/pf2/ [L]
Run Code Online (Sandbox Code Playgroud)

但它不起作用

编辑:

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]
Run Code Online (Sandbox Code Playgroud)

Rav*_*h13 5

使用您显示的样本,您能否尝试以下操作。请在测试您的 URL 之前清除您的浏览器缓存。

RewriteEngine ON 
RewriteCond %{REQUEST_URI} !^/example\.com/inter/pf2 [NC]
RewriteRule ^(.*)/?$ %{HTTP_HOST}/inter/pf2/$1 [L]
Run Code Online (Sandbox Code Playgroud)