Routing URLs in PHP

前端 未结 3 1446
孤独总比滥情好
孤独总比滥情好 2020-12-03 18:52

I\'m working on a web page project. I decided to use Apache, PHP (5.1.7, version imposed by my service provider) and Dwoo (templating) for this purpose.

I want to ro

3条回答
  •  情书的邮戳
    2020-12-03 19:17

    Use mod_rewrite to route everything to a single index.php file. Then check the variable in $_SERVER['REQUEST_URI'] within this file to dispatch to the required handler.

    This configuration will enable mod_rewrite, if it's installed:

    DirectorySlash Off
    Options FollowSymLinks Indexes
    DirectoryIndex index.php
    
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME}  -d
    RewriteRule  ^.*$  -  [L]
    
    RewriteCond %{REQUEST_FILENAME}  -f
    RewriteRule  ^.*$  -  [L]
    
    RewriteRule ^.*$    index.php [L]
    

提交回复
热议问题