如何在.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]

回答

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

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


以上是如何在.htaccess重定向然后重写的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>