使用.htaccess
我成功地重定向一組特定的子文件夾(博客,開發,媒體等),以子域。重定向一個子文件夾內特定的子目錄只
像這樣:
www.website.com/_subs/dev/foo
被引導到dev.website.com/foo
這已經與下面的代碼片段實現:
RewriteEngine on RewriteBase/ RewriteCond %{HTTP_HOST} ^website.com$ RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} website.com RewriteCond %{REQUEST_URI} ^/_subs/blog/(.*)$ RewriteRule .* http://blog.website.com/%1 [R=301,L] RewriteCond %{HTTP_HOST} website.com RewriteCond %{REQUEST_URI} ^/_subs/dev/(.*)$ RewriteRule .* http://dev.website.com/%1 [R=301,L] RewriteCond %{HTTP_HOST} website.com RewriteCond %{REQUEST_URI} ^/_subs/media/(.*)$ RewriteRule .* http://media.website.com/%1 [R=301,L]
的問題是:
如果不向我的某個特定子文件夾發出請求,如何防止訪問
/_subs
文件夾?
我想任何請求被以www.website.com/_subs/foo
作出簡單地重定向到www.website.com
我一直在使用301重定向以及其他各種嘗試無果:(
任何幫助將嘗試不勝感激。
乾杯