注意:我已經嘗試了this question下的建議,但它們要麼不起作用,要麼給我一個無限的重定向循環錯誤。使用Mod_Rewrite將ROOT重寫爲另一個路徑
我在我的.htaccess文件如下:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase/
# Rewrite old links to new
Redirect 301 /howitworks.php /how-it-works
Redirect 301 /testimonials.php /testimonials
Redirect 301 /contact_us.php /customer-service
Redirect 301 /affiliates.php /affiliates
Redirect 301 /account.php /customer/account
Redirect 301 /shopping_cart.php /checkout/cart
Redirect 301 /products.php /starter-kits
Redirect 301 /login.php /customer/account/login
# Force to Admin if trying to access admin
RewriteCond %{HTTP_HOST} www\.example\.com [NC]
RewriteCond %{REQUEST_URI} admin [NC]
RewriteRule ^(.*)$ https://admin.example.com/index.php/admin [R=301,L,QSA]
# Compress, Combine and Cache Javascript/CSS
RewriteRule ^(index.php/)?minify/([^/]+)(/.*.(js|css))$ lib/minify/m.php?f=$3&d=$2
# Always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
# Never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !server-status
# Rewrite everything else to index.php
RewriteRule .* index.php [L]
# Force www in url and non-example domains to example
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^ww2\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^qa\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^uat\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^local\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^admin\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L,QSA]
</IfModule>
我需要重寫,將做到以下幾點:
重寫:http://subdomain.example.com/到http://subdomain.example.com/page
我也想這隱藏/頁面(/會像/頁面一樣),但這不是必需的要求。另外,我希望它能夠使用HTTP或HTTPS。
任何幫助是非常感謝,因爲我一直在掙扎幾個小時。
這個問題屬於上ServerFault。 – leek 2010-10-11 06:42:41