Mod Rewrite Hide Folder

后端 未结 3 1882
庸人自扰
庸人自扰 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:48

    I assume what you want is for the browser to request /home.php but the server to actually use the file located at /pages/home.php, right? If so, this should work:

    Make sure the apache mod_rewrite module is installed. Then, use something like this in your apache config, virtual host config, or (less desirable) .htaccess file:

    RewriteEngine On
    RewriteRule ^/(.*)$   /pages/$1
    

    The rules use regular expressions, so you may want to look at a reference on that topic if you're unsure. Read the manual for more info on other directives (RewriteCond can be very useful) or rule options.

提交回复
热议问题