Home>
Thing I want to do

The file in sample.com/test/sample/ of the image migrated the site created by the root relative path
If this is left as it is, the path is incorrect and css, js, etc. are not displayed.

Without rewriting the file path
Only for files in the sample directory
I want to be able to display/sample/as the document root.

(Example of desired URL https://sample.com/test/sample/contact.html)

What I tried

I also thought about creating a subdomain and migrating the data in the sample folder.
If possible, I wanted to complete it under the test directory, and I wondered if I could do it with .htaccess.

Because the files under other roots also include websites and files that are open to the public
I want to do it so that there is no effect except under the sample directory.

I thought the URL below was the closest to what I wanted to do, so I tried to refer to it, but it didn't work.

Only for files in the sample directory
I would like to know how to display/sample/as the document root.

  • Answer # 1

    The "site root relative path" is basically an "absolute path", isn't it?

    RewriteEngine on
    RewriteRule ^ (css /. *) /Test/sample/$1
    RewriteRule ^ (js /. *) /Test/sample/$1


    Just below the document root, anothercssOrjsIf there are directories, they will all be rewritten, so
    In that case, you need to see the referrer.

    RewriteEngine on
    RewriteCond% {HTTP_REFERER} ^ https://example\.com/test/sample/
    RewriteRule ^ ((css | js) /.*) /test/sample/$1