html - Problems with CSS while using RewriteRule on .htaccess -


i'm having trouble while using rewriterule on local , remote servers.

here's situation i'm in right now:

localhost/puntvallesgit/index.php?seccion=nosaltres 

this actual url

i want renamed to:

localhost/puntvallesgit/nosaltres 

and

localhost/puntvallesgit/nosaltres/ 

both urls work, meaning, not give me 404 or that, but, second 1 (localhost/puntvallesgit/nosaltres/) there's no css nor js loading correctly.

looking html code, can see while using rule, url path js , css gets changed to:

localhost/puntvallesgit/nosaltres/css/styles.css yet code has this:

<link href="./css/styles.css" rel="stylesheet"> 

i understand sine i'm rewritting url, /nosaltres ... html code adapts new folder structure, not expected behaviour.

also, while using url without final slash (localhost/puntvallesgit/nosaltres) works great (under localhost).

i use absolute paths, yet, not ideal thing do, since paths change localhost remote server

here's htaccess rewrite i'm using:

<ifmodule mod_rewrite.c>     rewriteengine on     rewritecond %{script_filename} !-d     rewritecond %{script_filename} !-f      rewriterule ^([^/]*)$ index.php?seccion=$1 [nc]     rewriterule ^([^/]*)/$ index.php?seccion=$1 [nc] </ifmodule> 

some advice please? in advance

you can add base tag between <head> </head> section of site. asset folders read root.

<base href="/"> 

also rewritecond works first rewrite following it. can condense rule way.

<ifmodule mod_rewrite.c>     rewriteengine on     rewritecond %{script_filename} !-d     rewritecond %{script_filename} !-f     rewriterule ^([^/]*)/?$ index.php?seccion=$1 [nc,l] </ifmodule> 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -