Make domain folder act as root


New Member
I have a domain for example this domain contain a full project in
Whenever I write <link ref="stylesheets" href="/style/main.css"> it search in the domain root not in the system directory which the project in.
What I have tried to do:
I have tried to edit all my path to be equal to href="style/main.css" instead of href="/style/main.css".

This solution works but I won't do this every time I go in production mode.
What I am trying to do:
I know there is a solution using .htaccess but I don't know how to write it..


Thành viên BQT
<link ref="stylesheets" href="./system/style/main.css">
<link ref="stylesheets" href="../system/style/main.css">.
If it still won't work, use three dots.
<link ref="stylesheets" href=".../system/style/main.css">.
It has worked for me.

To set a subdirectory as root with .htaccess
It will depend, with some hosting services you only need to add this line:

RewriteBase   /system
If that doesn't works for you, try this:
RewriteEngine On
# Map to /system.
RewriteRule ^$ /system/ [L]
# Map to /system/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/system/
RewriteRule ^(.*)$ /system/$1
# Add trailing slash to directories within system
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^system/(.*[^/])$$1/ [R=301]

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.