开发者

htaccess: Custom redirect from any folder to home

I have site with these files and foldes:

/index.php ( that include php files开发者_如何学JAVA contained in folder1 and folder2 )
/config.php
/folder1/
/folder2/

I want this:

when a user point to any folder ( folder1, folder2 or any other folder ) then he is redirected to index.php

How could I do that ?


You want mod_rewrite. For example, to forward any request to any alphanumerically-named folder to index.php, passing the name of the folder as the GET parameter folder, use something like:

RewriteEngine on
RewriteRule ^([A-Za-z0-9]+)/?$ index.php?folder=$1
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜