如何将网站重定向到手机而不是图像文件夹?

发布于 2025-01-08 03:22:56 字数 448 浏览 3 评论 0原文

我已将此代码添加到我的 .htaccess 中

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /mobile/ [L,R=302]

,并且我在 http://www.exemple 中拥有所有图像。 com/imgs 文件夹。

当我尝试从手机加载这些图像时,由于重定向,路径似乎错误,即使我使用完整路径调用图像,它也不起作用。

是否有任何解决方法,以便重定向起作用并从存在的路径加载图像,而不是尝试通过强制重定向来加载它们?

I've added this code in my .htaccess

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /mobile/ [L,R=302]

and I have all of the images in the http://www.exemple.com/imgs folder.

When I try to load those images from my mobile, the path seems wrong because of that redirection and even if I call the image with the full path, it's not working.

Is there any workaround so the redirection works and loads images from the path where there are and not trying to load them with forcing the redirection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你又不是我 2025-01-15 03:22:56

以相同的顺序添加此内容:

RewriteCond %{REQUEST_URI} !^/imgs/ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /mobile/ [L,R=302]

另外,您是否错过了 RewriteRule ^(.*)$ /mobile/ [L,R 中的 /mobile/ 之后的 $1 =302]?

Add this in the same order:

RewriteCond %{REQUEST_URI} !^/imgs/ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /mobile/ [L,R=302]

also, did you miss, $1 after /mobile/ in RewriteRule ^(.*)$ /mobile/ [L,R=302]?

天冷不及心凉 2025-01-15 03:22:56

比如:

RewriteCond    $1    !^(imgs)

应该能解决问题

Something like:

RewriteCond    $1    !^(imgs)

should do the trick

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文