1

I searched but did not find a definitive answer for my question.

What is the best practice to include .css, .js, and other files? How do I declare it in my configuration file. I tried :

define('CONST_ADMIN_JAVASCRIPT_LOCATION', 'jscript/');

This works but i think is most elegant to define like this in index.php:

define( 'ADMIN_ROOT', realpath(dirname(__FILE__))); 

And then the css directory :

define('CONST_ADMIN_CSS_LOCATION', ADMIN_ROOT.'templates/default/css/');

So if i try this then when including css, js, and other files then I get an error : 404 Not Found

<link href="/var/www/html/mysite/adminarea/templates/default/css/default_admin.css.php "    rel="stylesheet" type="text/css">

The file is there so I'm thinking the .htaccess file restriction must be the problem.

This is my .htaccess file:

RewriteEngine on
# HTTP OVER SSL
#RewriteCond %{HTTPS} !on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect non-www to www
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Restricting direcotry listings
Options -Indexes

## RESTRICTING UPLOADS ONLY FOR IMAGE FILES
<Files ^(*.jpeg|*.jpg|*.png|*.gif)>
order deny,allow
deny from all
</Files>

So what is the best practice solution for this problem ?

Szekelygobe
  • 2,309
  • 1
  • 19
  • 25
  • You need to understand the difference between server/filesystem paths, and webserver/document_root-relative ones. – mario Jan 21 '17 at 15:41
  • Thanks! This is sooo constructive :) – Szekelygobe Jan 21 '17 at 16:46
  • 1
    See also: http://stackoverflow.com/questions/3678351/php-realpath-function-question, as well as http://stackoverflow.com/questions/1240462/php-convert-file-system-path-to-url, and lastly http://stackoverflow.com/questions/15481629/how-do-i-set-base-url-for-all-pages-of-my-website – mario Jan 21 '17 at 19:59
  • Much, much better, thank you :) – Szekelygobe Jan 21 '17 at 20:31

0 Answers0