Home>

I'm sorry if it's a rudimentary question. . .
I do n’t know how to search, but it ’s helpful if you just give me a hint.

1. Overview
It is a redirect to access a smartphone-dedicated page when accessed with a smartphone.

RewriteCond% {REQUEST_URI}! ^/(sp) /.*$
RewriteCond% {HTTP_USER_AGENT} (iPod | iPhone | Android | Windows \ Phone | BlackBerry | Symbian) [NC]
RewriteCond% {HTTP_COOKIE}! Vm = pc [NC]
## RewriteRule ^ (/? | Index.html) $sp/index.html [L] ## Incorrect display that CSS is not applied
## RewriteRule ^ (/? | Index.html) $/sp/[L] ## Incorrect display that CSS is not applied
## RewriteRule ^ (. *) $Sp/$1 [L] ## This will result in a 500 error
## RewriteRule ^ (/? | Index.html) $sp/sitemap.html [L] ## Incorrect display that CSS is not applied
## RewriteRule ^ (/? | Index.html) $index.html [L] ## This is normal display (top page of PC site. With CSS and images)
## RewriteRule ^ (/? | Index.html) $html/p/c/c_2.html [L]
## RewriteRule ^ (/? | Index.html) $kensaku/[L] ## This is normal display (PC site search page. CSS and images available)
RewriteRule ^ (/? | Index.html) $sp/test.html [L] ## Normal display (CSS, no image)

2. File hierarchy
htaccess
sp/index.html
(The htaccess and sp directories are in the same directory and index.html is directly under the sp directory.)

3. Symptom
When this index.html is accessed under the following conditions, images without CSS etc. are displayed in a very simple html that is not loaded.
Device: iPhone
Browser: Chrome
URL "https://test.site/"

However, the contents of sp/index.html are displayed normally under the following conditions.
Device: iPhone
Browser: Chrome
URL "https://test.site/sp/"

In addition, as I commented in the htaccess code, I tried it on sp/test.html and on the PC site, but it appears correctly only when there are CSS and images under the sp directory. not.

Why is it not displayed correctly when accessed via htaccess?
Where should I look up?

Addition 1:
RewriteRule ^ (/? | index.html) $https://test.site/sp/ [L]


And then I started to transition normally,
Absolute path within the same site? Is there a problem with redirecting with a URL?
I would like to know the merits and demerits of using an absolute path to redirect to a smartphone-dedicated page in the same site.
(Or just search keywords to get that knowledge ...)

I'm wondering if this is okay,
Regardless of the site, the redirect to the smartphone page was RewriteRule ^ (/? | Index.html) $/sp/[L] and only the directory specified,
The test.site created by us is operating normally with RewriteRule ^ (/? | Index.html) $/sp/[L] before renewal (when it was placed on another rental server). It was.

Is there any reason why there are many sites that only specify a normal directory, including the site before the renewal? I think, how is it?

  • Answer # 1

    RewriteRule ^ (/? | index.html) $https://test.site/sp/ [L]


    And it worked fine by writing the absolute path.

  • Answer # 2

    Finally,

    RewriteRule ^ (. *) $sp/$1 [L]


    Then what?