有人能帮我把php页面重定向到html(只在根目录,没有子文件夹)吗?我尝试了几十个解决方案,但都没有成功。下面的代码重定向到所有地方(包括子文件夹)我不希望子目录受到影响。我的域:https://www.example.com/提前感谢!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+?)\.php$ /$1.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)\.html$ /$1.php [L]
</IfModule>
<FilesMatch ".(ico|css|flv|js|gif|jpeg|png|woff|woff2|eot|svg|ttf|webp)$">
Header set Cache-Control "max-age=604800, public, no-cache"
</FilesMatch>
2条答案
按热度按时间u0sqgete1#
pu3pd22g2#
有这样的话:
请注意,
[^./]
将匹配任何不是点和/
的字符,因此仅在根目录中匹配,跳过所有子目录。