About setting up .htaccesses to redirect PCs and smartphones

Asked 5 months ago, Updated 5 months ago, 17 views

Because the URL of the PC site and the smartphone site are different, I tried to redirect them, and I set only the root domain of the server by writing the following in .htaccess.

When I accessed the top page of PC with my smartphone, it switched well, but the bottom page of PC is not reflected (it does not switch to the smartphone page).If you transition from the top page of the smartphone site to the bottom page (of course), the smartphone site will come out properly.If you enter the PC lower page directly, it will not switch to the smartphone lower page.Could you tell me what's wrong?

.htaccess describes:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond%{HTTP_USER_AGENT} (iPhone | Android.* Mobile | Windows.* Phone) [NC]

The URL is as follows:

PC site http://www.〇 ..com/ or http://www.〇 ..com/index.html
Smartphone site http://www.〇〇.com/smt

PC Site http://www.〇 com.com/△△△.html
Smartphone site http://www.〇 com.com/smt/△△△.html

I apologize for the inconvenience, but I appreciate your cooperation.


2022-09-30 11:57

1 Answers

For .htaccess, the RewriteRule is subject to the RewriteRule where the first // 」 of the path // が is omitted. /
The ^$ of the current setting only covers the path // 」, so it is only the top page.
Consider a rule that excludes s/smt/ 」 from regular expressions, backward references, and redirect loops.

"If ""/some path"" → ""/smt/some path,"" the following settings are used:


2022-09-30 11:57

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.