在URL中使用.htaccess隐藏文件夹



如何将URL从显示:www.example.com/p/tools更改为仅显示www.example.com/tools?

我试着玩。htaccess一点点,但不幸的是不能使它工作。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
</IfModule>

根据您所展示的样品,您可以尝试以下操作吗?

请确保在测试url之前清除浏览器缓存

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteRule ^p/(.*)/?$ $1 [NC,R=301,L]
RewriteCond %{THE_REQUEST} /([^.]+).html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
</IfModule>

最新更新