简体   繁体   English

使用htaccess从URL中删除目录名称

[英]Remove directory name from URL using htaccess

I have bunch of folders and files in folder "front". 我在文件夹“ front”中有一堆文件夹和文件。 I want to remove "front" from url. 我想从网址中删除“前”。 I write htacess but it gives 404 error. 我写的htacess,但它给404错误。

RewriteEngine On
RewriteBase /
RewriteRule ^front/(.*)$ /test/$1 [L,NC,R]

I want to rewrite url like this : 我想这样重写网址:

http://localhost/test/front/abc/abc.php

to

http://localhost/test/abc/abc

You have it back to front 你有回到前面

RewriteEngine On
RewriteBase /
RewriteRule ^test/(.*)$ /test/front/$1 [L,NC,R]

Try adding this to the htaccess file in your document root, preferably above any rules you may already have there: 尝试将其添加到文档根目录中的htaccess文件中,最好在您可能已经在此处拥有的所有规则之上:

RewriteEngine On
RewriteRule ^test/(.*)$ /front/$1 [L,R=301]

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

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