我的根文件夹中网站的HTML到PHP重定向?
我最近将我的网站移至wordpress。我需要将我的我的根文件夹中网站的HTML到PHP重定向?,php,html,.htaccess,redirect,http-status-code-301,Php,Html,.htaccess,Redirect,Http Status Code 301,我最近将我的网站移至wordpress。我需要将我的.html重定向到.php。由于我的网站位于根文件夹中,我不希望.htaccess中的任何重定向影响我的子文件夹和其中的其他网站 是否有规则可以将它们重定向到我的特定网站?使用.htaccess应该是最好的方法 # This allows you to redirect your entire website to any other domain Redirect 301 / http://mt-example.com/` # This a
.html
重定向到.php
。由于我的网站位于根文件夹中,我不希望.htaccess
中的任何重定向影响我的子文件夹和其中的其他网站
是否有规则可以将它们重定向到我的特定网站?使用.htaccess应该是最好的方法
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/`
# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/`
# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html
这里还有一个关于如何创建.htaccess和编辑的视频
在根htaccess的顶部,放置以下内容:
RewriteEngine on
RewriteRule ^(.+)\.html$ /$1.php [L,R]
这会将所有html请求重定向到php,例如:/file.html到/file.phpR是一个临时重定向标志,当您确定规则正常工作时,可以将其更改为R=301永久重定向