Pregunta

i was enabling clean urls by editing .htacces with the following code

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9]+)/(.+)/$ index.php?page=$1&option=$2 [L]
RewriteRule ^([a-zA-Z0-9]+)/(.+)$ index.php?page=$1&option=$2 [L]
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1 [L]

i don't know much about .htaccess and did this much googling. My problem now is that i cannot load .js , .css and other files from my server. I am getting the 404 error page i made to show when requested page is not there

how can i make my css and js load??

¿Fue útil?

Solución

create directory statics and put static file there.

/
|__ .htaccess
|__ statics
|  |__style.css
|  |__script.js
|__ some directory

edit your .htaccess like this:

RewriteEngine On
RewriteRule ^statics/ - [L,NC]

#your codes

Otros consejos

Be sure that your paths to your css/js/image files are relative to the domain instead of the page (e.g. use /yourdomain/styles.css instead of yourdomain/styles.css). Add a rewrite condition like this to your htaccess:

RewriteCond $1 !^(favicon\.ico|favicon\.png|media|robots\.txt|crossdomain\.xml|css|js)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top