這是我正在使用的 .htaccess。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule (.*)$ https://sub.example.com/$1 [R=301,L]
</IfModule>
當請求像 path1/path2/index.html 這樣的特定檔案路徑時,它可以正常作業并且不會重寫。但是,如果請求像 path1/path2/ 這樣的路徑,即使該目錄中有像 index.html 這樣的 DirectoryIndex 檔案,它也會重定向。有什么簡單的方法可以解決這個問題?
uj5u.com熱心網友回復:
正如我在上面的評論中建議的那樣,這樣的事情應該可以作業:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . https://sub.example.com%{REQUEST_URI} [R=301,L,NE]
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/510600.html
上一篇:Linux上的ASP.NETCore6ReactJSWeb應用程式存在IDX10634問題:無法創建SignatureProvider
