Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache 将.html替换为/在htaccess上_Apache_.htaccess - Fatal编程技术网

Apache 将.html替换为/在htaccess上

Apache 将.html替换为/在htaccess上,apache,.htaccess,Apache,.htaccess,我有以下代码: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.html$ /$1 [L,R=302] 我想将.html替换为/,但代码只删除了.html 例如: example.com/page.html至example.com/page/ 谢谢大家! 您只需在/$1的末尾添加一个/ 所以这一行: RewriteRule ^(.*)\.html$ /$1 [L

我有以下代码:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=302]
我想将.html替换为/,但代码只删除了.html

例如: example.com/page.html至example.com/page/


谢谢大家!

您只需在/$1的末尾添加一个/

所以这一行:

RewriteRule ^(.*)\.html$ /$1 [L,R=302]
变成:

RewriteRule ^(.*)\.html$ /$1/ [L,R=302]
这将为您提供所需的URL

完成工作。访问代码:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1/ [L,R=302]