1. 程式人生 > >PHP 使用.htaccess配置實現二級域名,RewriteCond,RewriteRule

PHP 使用.htaccess配置實現二級域名,RewriteCond,RewriteRule

例如:

需要實現訪問blog.ooxiang.cn 時跳轉到ooxiang.cn/blog/目錄,可以在/htdocs資料夾下建立.htaccess檔案,在.htaccess檔案寫入以下程式碼:


RewriteCond %{HTTP_HOST} ^blog.ooxiang.cn [NC] 
      RewriteRule ^(.*)$ http://ooxiang.cn/blog/$1 [L,R=301]