简体   繁体   English

htaccess在两个方向上从url隐藏文件夹名称

[英]htaccess hide folder name from url in both directions

I want my urls to look nice. 我希望自己的网址看起来不错。 So when I have this url: 所以当我有这个网址:

localhost/pages 本地主机/页

I want the url to look like this: 我希望网址看起来像这样:

localhost/ 本地主机/

I already solved, that when I type in localhost/pages I get the index file from /pages, but when I type in /pages it is still showing: 我已经解决了,当我输入localhost / pages时,我从/ pages获得了索引文件,但是当我输入/ pages时,它仍然显示:

localhost/pages. 本地主机/页。

How can I change, that /pages is not shown? 如何更改/ pages不显示?

My htaccess code: 我的htaccess代码:
RewriteEngine on RewriteBase /RewriteCond %{REQUEST_URI} !^/pages/ RewriteRule ^(.*)$ /pages/$1 [L]

Your current rewrite rule redirects localhost/foo to localhost/pages/foo and it serves localhost/pages/foo . 您当前的重写规则将localhost/foo重定向到localhost/pages/foo ,并且服务localhost/pages/foo Change your rewrite rule to: 将您的重写规则更改为:

RewriteRule ^pages/(.*)$ $1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM