Mod Rewrite Hide Folder

后端 未结 3 1869
庸人自扰
庸人自扰 2020-12-09 22:21

I think this is a pretty simple question.

How do you an apache rewrite to hide a folder.

EX: www.website.com/pages/login.php to www.website.com/login.php

3条回答
  •  失恋的感觉
    2020-12-09 22:38

    I know the original post here was from a couple years ago, but it's been coming up first in the search engine, so maybe this will help others looking to hide a folder name in the URL.

    Not exactly what original poster wanted, but along the same lines.

    RewriteCond %{HTTP_HOST} ^mydomainname\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mydomainname\.com$
    RewriteCond %{REQUEST_URI} !^/subfoldername/
    RewriteRule (.*) /subfoldername/$1
    

    The above example would redirect any request to mydomainname.com or www.mydomainname.com to the subfoldername directory in the root directory for the domain, and the subfolder name would not appear in the URL.

提交回复
热议问题