[英].htaccess Redirect 301 - can't load files from mobile directory
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|ipad|iemobile" [NC]
RewriteRule ^((?!m/).*)$ /m/$1 [R=301,L]
這就是我Web服務器根目錄中的.htaccess的樣子。 它成功重定向到/ m,但不會從我的根目錄加載文件。 我在移動目錄中使用../js和../css從其父目錄加載此類文件。 / m文件夾尚沒有.htaccess。
從規則中排除文件和目錄:
RewriteEngine On
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|ipad|iemobile" [NC]
RewriteRule ^((?!m/).*)$ /m/$1 [R=302,NE,NC,L]
您也可以嘗試在頁面的HTML部分中添加以下內容:
<base href="/" />
以便從該URL而不是當前頁面的URL解析每個相對URL。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.