更新时间:2022-11-26 13:11:47
为什么不来路由所有请求与mod_rewrite的的index.php文件,并使用PHP编写路由逻辑,这似乎这样更可靠的方式比写不同的重写规则?
Why not to route all requests to the index.php with mod_rewrite and use PHP to write the routing logic, which seems way more reliable way than writing distinct rewrite rules?
这么简单的.htaccess这一个
As simple .htaccess as this one
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?request=$1 [QSA,L]
和在index.php几行PHP code
And few lines of PHP code in the index.php
$client_name = strtok($_SERVER['HTTP_HOST'],".");
list ($cat,$subcat) = explode("/",trim($_GET['request'],"/"));