开发者

htaccess to skip a folder

I see htaccess questions all over the place but I cant seem to get the thing to do what I want. Im not sure if a redirect or a rewrite is what I need.

Im looking for a way to use a sub folder but make it look there is not a subfolder.

I have a bunch of folders in the root of my domain:

www.mysite.com/folder1
www.mysite.com/folder2
www.mysite.com/folder3
www.mysite.com/folder4

Id like to be able to move folder1 and folder2 to a su开发者_运维技巧bfolder but not have that folder visible to the user. For example

www.mysite.com/x/folder1
www.mysite.com/x/folder2
www.mysite.com/folder3
www.mysite.com/folder4

But the user would still see it as it originally was.

It seems like I would have to use a redirect and a rewrite. If a user goes to www.mysite.com/folder1 the will actually be in www.mysite.com/x/folder1 without knowing that they are in that subfolder.

Of course I need to do this without disrupting folder4 and folder5. Ideas? Tips? Tricks? Im not too familiar with htaccess


This is what worked for me, maybe it will help someone else:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1

This is telling the server to ignore the Public folder, so when my URL is actually mysite.com/public/file it shows and responds to mysite.com/file

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜