Apache ~ Rewrite example ~

.htaccess
--------------------------------------------------------------------------------
RewriteEngine on

RewriteRule ^products/([A-Za-z0-9_]+)/?$ category.php?c=$1 [L]

RewriteRule ^products/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/?$ product.php?name=$1&id=$2 [L]
--------------------------------------------------------------------------------

這個範例是

假如.htaccess所在的目錄~~~是在網址http://qoo.com

那麼連到
htpp:/qoo.com/products/xxxxxxxxxxxxxxxxxxxxx

實際上會連到
htpp:/qoo.com/catogory.php?c=xxxxxxxxxxxxxxxxxxxxx


連到
htpp:/qoo.com/products/xxxx/yyyyyyyyyy

實際上會連到
htpp:/qoo.com/product.php?name=xxxx&id=yyyyyyyyyy

沒有留言:

發佈留言