Category Archives: base

Angular2 Keeping base href to / with Apache

my directory structure looks like this,

DocumentRoot
|_test
    |_api
    |_app
    |_index.html
    |_etc1
    |_etc2

I'm running Apache on my local test server, it seems that when i browse to "localhost/test", I am seeing that my webpage is not formatted correctly, this is because it couldn't locate all the css files required, the pathing looks something like "localhost/etc1/test.css" instead of "localhost/test/etc1/test.css".

I can resolve the above issue by changing the base href in my index.html file to "test".

The refreshing of the page also works with the addition of the following .htaccess that I put under test directory.

DocumentRoot
|_test
    |_api
    |_app
    |_index.html
    |_etc1
    |_etc2
    |_.htaccess


<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . index.html [L]
</IfModule>

Is there anyway I could keep the base href to "/" instead of "/test/"?

Why use base href for .htaccess

here is my .htaccess code

Options -MultiViews
RewriteEngine On
RewriteRule ^([^/]+)-([^/]+)-([^/]+)/?.html$ movies.php?m=$3&id=$2&lang=$1 [NC,L,QSA]

here in movies.php page i need to use <base href="/"> why? is here any process to use same .htaccess but not use <base href="/"> ? or can i do same work with any other process? PLease help me