Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的根文件夹中网站的HTML到PHP重定向?_Php_Html_.htaccess_Redirect_Http Status Code 301 - Fatal编程技术网

我的根文件夹中网站的HTML到PHP重定向?

我的根文件夹中网站的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

我最近将我的网站移至wordpress。我需要将我的
.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永久重定向