简体   繁体   English

使用.htaccess问题从网址中删除文件夹

[英]Remove folders from url using .htaccess issue

Hi So I am trying to remove includes/pages from a url that looks like http://localhost:8888/london/includes/pages/soho-london-guide/ For local dev. 您好,我想从看起来像http://localhost:8888/london/includes/pages/soho-london-guide/的url中删除includes/pages I am using MAMP and I've enabled mod_rewrite too. 我正在使用MAMP,并且也启用了mod_rewrite

So far I've been trying to use different techniques and here is a list of what I've been using (trying to make it work :((( ) 到目前为止,我一直在尝试使用不同的技术,这是我一直在使用的列表(试图使其工作:((()

RewriteEngine ON
RewriteRule ^includes/pages/(.*)$ $1 [L,QSA]

Also

RewriteEngine on
RewriteBase /
RewriteRule ^/includes/pages/(.+)$ /$1 [L,QSA]

Very very new to .htaccess and regex syntax so any help would be appreciated. .htaccess和regex语法非常新,因此可以提供任何帮助。

Have this rule in your site root .htaccess: 在您的网站根目录.htaccess中有以下规则:

RewriteEngine on
RewriteBase /

RewriteRule ^([\w-]+)/(?!includes/pages/)(.+)$ $1/includes/pages/$2 [L,NC]

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

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