当我的网站不使用.html扩展名时,如何将单个网页从/this-is-a-test-page
重定向到/test-page
的301?这是我当前的.htaccess代码,如果用户未键入www。和https,则会强制使用www和https,并允许我使用html代码中不含.html扩展名的链接,例如:<a href="https://www.example.com/this-is-a-test-page">
:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
我尝试将其添加到代码末尾:
Redirect 301 /this-is-a-test-page /test-page
但是那什么也没做。但是,如果我将.html扩展名添加到旧地址和新地址中,它将起作用,但是它将重定向到带有.html扩展名的新页面,该扩展名显示了我不需要的内容,并且我的html链接不使用.html扩展名。有什么想法吗?