I am developing the website in my local server in a root folder, the problem is that when my client told me to upload the website in to their server, it is located in the subfolder. So the url has been like this. http://example.com/myproject
The problem with that format is that all my css,js, ajax calls are messed up because when I tried to check Firebug/chrome console, I am seeing a http://example.com/assets/css/main.css , where in fact it should be http://example.com/myproject/assets/css/main.css
All my scripts are coded to be like this:
<link rel="stylesheet" href="/assets/css/main.css"> since that works perfectly when the project is not in a subfolder.
My question now is that, is there a trick, maybe in the .htaccess or mod_rewrite that would allow me to tell the browser that always add a /myproject in all my script calls?
The reason for this is that I don't want to change all my script calls and add a /myproject/...
This is the sample of my .htaccess:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Allow asset folders through
RewriteRule ^(fuel/modules/(.+)?/assets/(.+)) - [L]
# Protect application and system files from being viewed
RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]
# Prevents access to dot files (.git, .htaccess) - security.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
Options -Indexes
Your help will be greatly appreciated! Thanks!
In Unix based filesystems (which the web path is based on), the / at the beginning of a path is an absolute path to the root level.
For web addresses, this means it goes directly to the document root of your website.
You will need to remove the beginning / from your href attributes