简体   繁体   English

使用 htaccess 从 url 中删除文件夹

[英]remove folder from url with htaccess

So I have a folder named pages which includes the pages for my site, when opening one of these files the url reads -所以我有一个名为 pages 的文件夹,其中包含我网站的页面,当打开其中一个文件时,url 会读取 -

zebrafishweb/pages/contact zebrafishweb/pages/contact

I would like it to just read我希望它只是阅读

zebrafishweb/contact斑马鱼网/联系方式

I already have this htaccess file to remove any.php.html extensions which i would also like to carry on using.我已经有这个 htaccess 文件来删除我还想继续使用的任何.php.html 扩展。 I don't have a clue how to write these htaccess files just copied it from the web and tailored it to me!我不知道如何编写这些 htaccess 文件,只是从 web 复制并为我量身定制!

 RewriteEngine on

 RewriteRule ^(themes|order-now|submissions|faq|contact)$ $1.php [NC,L]
 RewriteRule ^(home|faq)$ $1.html [NC,L]

With your shown samples please try following .htaccess Rules file.对于您显示的示例,请尝试遵循 .htaccess 规则文件。 Make sure to clear your browser cache before testing your URLs.确保在测试 URL 之前清除浏览器缓存。

RewriteEngine on
RewriteBase /zebrafish/pages/

RewriteRule ^zebrafish/pages/contact/?$ /contact? [R=301,NC,L]

RewriteRule ^(themes|order-now|submissions|faq|contact)$ zebrafish/pages/$1.php [NC,L]
RewriteRule ^(home|faq)$ $1.html [NC,L]

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

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