Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.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
Php .htaccess 301重定向和删除.html组合_Php_Html_Apache_.htaccess_Redirect - Fatal编程技术网

Php .htaccess 301重定向和删除.html组合

Php .htaccess 301重定向和删除.html组合,php,html,apache,.htaccess,redirect,Php,Html,Apache,.htaccess,Redirect,我正在尝试将所有.html文件从stripelatice_ui文件夹重定向到root并删除.html扩展名 localhost:8089/stripelatice_ui/home.html 到 我试过使用 RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [QSA,NC,L] RewriteRule ^stripelatice_ui/(.*)$ /$1 [R=301,NC,L] 但如果说页面具有重定向循环

我正在尝试将所有.html文件从stripelatice_ui文件夹重定向到root并删除.html扩展名

localhost:8089/stripelatice_ui/home.html

我试过使用

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [QSA,NC,L]


RewriteRule ^stripelatice_ui/(.*)$ /$1 [R=301,NC,L]
但如果说页面具有重定向循环,则会出现错误,您可以使用:

RewriteEngine On
RewriteBase /stripelatice_ui/

# To externally redirect /stripelatice_ui/file.html to /file
RewriteCond %{THE_REQUEST} /stripelatice_ui/(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)/?$ $1.html [L]

实际上,我想将/stripelatice_ui/file.html重定向到/filefirst规则正在工作,但/file.html和/file都没有被服务器服务。在我的回答中添加了未发现错误,不知道您的.htaccess位于
stripelatice\u ui
目录中。
RewriteEngine On
RewriteBase /stripelatice_ui/

# To externally redirect /stripelatice_ui/file.html to /file
RewriteCond %{THE_REQUEST} /stripelatice_ui/(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)/?$ $1.html [L]