我在.htaccess
文件中遇到了一個小問題,我查看了一些堆棧鏈接,但無法解決我的問題。多站點條件.htaccess
我主持了多域名網站,我要的是:如果有一個子域,我訪問此網址
subdomain1.example.com/sitemap.xml
subdomain2.example.com/sitemap.xml
這應該從subdomains/subdomain1
拿起sitemap.xml的文件subdomains/subdomain2
分別與這條規則的偉大工程:
RewriteCond %{HTTP_HOST} ^(.*)\.example(.*).com [NC]
RewriteRule ^(sitemap.xml|robots.txt)$ subdomains/%1/$1 [L,NC]
如果www.example.com
然後皮卡來自項目根文件夾的sitemap.xml。
我已經試過這一點,但不工作:
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(sitemap.xml|robots.txt)$ http://www.example.com/$1 [L,NC]
它給了我500 internal server
錯誤。
任何幫助?
無論何時遇到500錯誤,絕對首先要考慮你總是去檢查服務器的錯誤日誌。 – CBroe
它導致我重定向循環。 –