Home>

I want to sort smartphones and PCs with htaccess.
The composition is
・ PC
/
・ SP
/ sp /
So, you can switch only to the top page of PC and SP.

Corresponding source code
RewriteEngine on
RewriteBase /
RewriteCond% {REQUEST_URI}!/Sp /
RewriteCond% {HTTP_USER_AGENT} (iPod | iPhone | Android. * Mobile | Windows. * Phone)
RewriteRule ^ (. *) $Sp/$1 [L, R = 301]
RewriteCond% {REQUEST_URI}/sp /
RewriteCond% {HTTP_USER_AGENT}! (iPod | iPhone | Android. * Mobile | Windows. * Phone)
RewriteRule ^ sp/(. *) $$1 [L, R = 301]
The problem i am having

I switch between PC and SP by redirect, but I can't read images in the "/" layer that are not in the "/ SP /" layer on the smartphone site.

What I tried

I tried changing the path, but it didn't work.

  • Answer # 1

    Images in the "/" layer that are not in the "/ SP /" layer cannot be read on the smartphone site.

    Since things that are not under/sp/are redirected to under/sp /, you cannot see directly under/as described.
    / If there is something directly under you that you want to exclude redirects,RewriteCondShould I exclude it with?