I have a domain for example https://test.com
this domain contain a full project in https://test.com/system
.
Problem:
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..
Try
<link ref="stylesheets" href="./system/style/main.css">
or
<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.
.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 http://www.example.com to /system. RewriteRule ^$ /system/ [L] # Map http://www.example.com/x 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/(.*[^/])$ http://www.example.com/$1/ [R=301]