S
S
Stanislav2016-05-31 19:25:00
PHP
Stanislav, 2016-05-31 19:25:00

How to set scripts and styles for localhost?

There is a setting in the Apache config:
DocumentRoot "e:/Desktop/Server/data/htdocs"
Actually, localhost "starts" from here.
How (apart from the browser add-on) can be attributed to the localhost'a js/styles/php page? And is it technically possible?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
novrm, 2016-05-31
@Stasgar

"C:\xampp\apache\manual\howto\index.html.en"

M
Maxim Timofeev, 2016-05-31
@webinar

styles and js can be applied to any html page, no matter where it is located. It is difficult to understand from your question what you mean by localhost, I assume that some page that is loaded in the browser. Accordingly, just add links to css and js in its head

M
Maxim, 2016-05-31
@m77x

links to localhost:
href="css/style.css" - in the current directory in the css folder style.css file
href="/css/style.css" - from the site root css folder style.css file
href="../ css/style.css" - exit the current directory to a higher level, find the css folder in it and load the style.css file

A
Aleksei_Iv, 2022-03-07
@Aleksei_Iv

If I understood the question correctly, then in order to connect the styles, I did the following on Openserver, where Apache 2.4.
Made changes to the server configuration file for the HeaderName and IndexOptions directives for the mod_autoindex module.
It became like this:
HeaderName /include/HEADER.html
IndexOptions SuppressHTMLPreamble FoldersFirst FancyIndexing HTMLTable VersionSort NameWidth=*
HeaderName contains a file that is included at the top of the page (placed in the include directory)
Only the SuppressHTMLPreamble directive has been added to IndexOptions. It removes the html from the top of the page, which is there by default.
In the header.html (the usual top of the html file), you need to remove everything after the body tag (this was in the Apache documentation itself), respectively, write the styles you need in the head tags. There is also an IndexHeadInsert directive for the same mod_autoindex, but it only works on the first page, as you can guess from the name. You could probably still look in the mod_autoindex documentation, but I stopped there. When I open localhost, I see this (of course, only when I just navigate directories):
6225fcbe5e797850875465.jpeg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question