Table of Contents
回复内容:
Home Backend Development PHP Tutorial HTML ,form 和 link 使用根目录 的问题,我已经上图了!

HTML ,form 和 link 使用根目录 的问题,我已经上图了!

Jun 06, 2016 pm 08:08 PM
apache css html php

我这个问题比较我觉得很疑惑了,我先说说环境,

我的服务器主目录是 C:\AppServ\www ,
我在主目录下写了个 01.php 文件,也就是 C:\AppServ\www\01.php ,
然后在某个位置写了个 *.html 文件 其中有个表单:

<code><form action="/01.php" method="get">
    <input type="text" name="bName" value="" class="">
    <input type="submit" value="提交">
</form></code>
Copy after login
Copy after login

然后提交后,成功了!!
HTML ,form 和 link 使用根目录 的问题,我已经上图了!

但是

我也在主目录下写了个css.css文件,也就是 C:\AppServ\www\css.css;

<code>我用<link rel="stylesheet" type="text css" href="/css.css">导入css样式表,结果失败!
但是用 <link rel="stylesheet" type="text css" href="/www/css.css">导入样式表,结果成功了!</code>
Copy after login
Copy after login

HTML ,form 和 link 使用根目录 的问题,我已经上图了!


为什么同样是html,

用 action="/01.php" 就是根目录,
中导入样式表 href="/css.css" 就不是根目录?

这是怎么回事?????

回复内容:

我这个问题比较我觉得很疑惑了,我先说说环境,

我的服务器主目录是 C:\AppServ\www ,
我在主目录下写了个 01.php 文件,也就是 C:\AppServ\www\01.php ,
然后在某个位置写了个 *.html 文件 其中有个表单:

<code><form action="/01.php" method="get">
    <input type="text" name="bName" value="" class="">
    <input type="submit" value="提交">
</form></code>
Copy after login
Copy after login

然后提交后,成功了!!
HTML ,form 和 link 使用根目录 的问题,我已经上图了!

但是

我也在主目录下写了个css.css文件,也就是 C:\AppServ\www\css.css;

<code>我用<link rel="stylesheet" type="text css" href="/css.css">导入css样式表,结果失败!
但是用 <link rel="stylesheet" type="text css" href="/www/css.css">导入样式表,结果成功了!</code>
Copy after login
Copy after login

HTML ,form 和 link 使用根目录 的问题,我已经上图了!


为什么同样是html,

用 action="/01.php" 就是根目录,
中导入样式表 href="/css.css" 就不是根目录?

这是怎么回事?????

首先你还要确定下,你的.css文件在你的web服务器上还有没有其它的路径映射的配置。 如果web服务器有对url的访问做路径配置,可能跟实际文件的物理路径是有差别的。
比如,假设你用nginx,作为服务器,指定.css的文件都从C:\AppServ路径开始:

<code>location ~ \.css{
    root C:\AppServ;
}
</code>
Copy after login

那么你要访问到 C:\AppServ\www\css.css。 那你页面中的url就的确要使用/www/css.css了。 而php文件的访问路径却不会受这条配置的影响。

你确定你引入css的html文件和css文件在同级目录?

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1248
24
HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Which 2025 currency exchanges are more secure? Which 2025 currency exchanges are more secure? Apr 20, 2025 pm 06:09 PM

The top ten safe and reliable exchanges in the 2025 cryptocurrency circle include: 1. Binance, 2. OKX, 3. Gate.io (Sesame Open), 4. Coinbase, 5. Kraken, 6. Huobi Global, 7. Gemini, 8. Crypto.com, 9. Bitfinex, 10. KuCoin. These exchanges are rated as safe and reliable based on compliance, technical strength and user feedback.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

How to import the source code of wordpress How to import the source code of wordpress Apr 20, 2025 am 11:24 AM

Importing WordPress source code requires the following steps: Create a sub-theme for theme modification. Import the source code and overwrite the files in the sub-topic. Activate the sub-theme to make it effective. Test the changes to make sure everything works.

NGINX and Apache: Understanding the Key Differences NGINX and Apache: Understanding the Key Differences Apr 26, 2025 am 12:01 AM

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

HTML as a Markup Language: Its Function and Purpose HTML as a Markup Language: Its Function and Purpose Apr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

See all articles