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

使用.htaccess在URL中隐藏文件夹,.htaccess,url-rewriting,.htaccess,Url Rewriting,如何将我的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_FILE

如何将我的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>

重新启动发动机
重写cond%{SERVER_PORT}80
重写规则^(.*)$https://www.example.com/$1[R,L]
RewriteCond%{REQUEST_FILENAME}.html-f
重写规则^%{REQUEST_URI}.html[NC,L]

根据您展示的样品,请尝试以下内容

请确保在测试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>

重新启动发动机
重写cond%{SERVER_PORT}80
重写规则^(.*)$https://www.example.com/$1[R,L]
重写规则^p/(.*)/?$$1[NC,R=301,L]
RewriteCond%{THE_REQUEST}/([^.]+)\.html[NC]
重写规则^/%1[NC,L,R]
RewriteCond%{REQUEST_FILENAME}.html-f
重写规则^%{REQUEST_URI}.html[NC,L]

欢迎来到SO,请在您的问题中分享您的htaccess规则文件谢谢you@RavinderSingh13谢谢你的好意。我刚马上上传了!:-)嗯,我是说。p现在不见了,但我还有一个问题。URL现在变为:
https://www.example.com/public_html/tools
并给我一个“404未找到”错误:/@Berkanktk,我真的考虑过了,那么对于不存在的文件和目录,您希望将其重写到哪个文件(index.php或index.html)?如果你能让我知道这个问题,我可以解决它,干杯。对不起,但我不确定我是否理解你的意思。不过我有一个html.index。如果有帮助的话?是的,很抱歉现在是3点,我是丹麦人,所以很快就轮到我了:p。好的,这就是,所有的:,和@RavinderSingh15好的,非常感谢!也为你干杯!:-)