服务器上运行的href标签错误 [英] href tag error running on server

查看:53
本文介绍了服务器上运行的href标签错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.

最近,我使用href标记将Web应用程序移动到了服务器上,这使我很难受.我的文件在本地放置在根文件夹中.但是在服务器上,它放置在另一个文件夹中.当我从一页调用href标记转到另一页时,出现错误,提示找不到该页面,这似乎是正确的.

我尝试了<a><\a>,也尝试了<a><\a>.

两种方式都可以在我的机器上本地正常运行,但不能在服务器上正常运行.
为什么会发生这种情况,并且有解决方法?我想用jquery替换我的html代码以打开其他页面.

任何建议都可以.

关于

Hi there.

I recently moved my web application onto the server with the href tag giving me hard times. Locally my files are placed in the root folder. But on the server it''s placed in another folder. When I call the href tag from one page to go to another it gives an error saying the page is not found which seem to be correct.

I tried <a><\a>, and also <a><\a>.

Both ways work fine locally on my machine but not on the server.

Why is this happening and is there a work around? I thought of replacing my html code with jquery to open other pages.

Any advise will do please.

Regards

推荐答案

T 这里没有 href 标签. href a 标记的属性. a 用于锚点.
标签以/而不是\闭合,因此
There is no href tag. href is an attribute of the a tag. a is for anchor.
Tags are closed with a / not a \ so
<a href="example.com">Example</a>

是有效的.

您的问题是您未正确链接到文件.

T 在整个解决方案中,您需要始终链接到您自己的Directoy结构中的位置.如果您永远不会移动项目,则可以始终将href属性设置为

is valid.

Your problem is that you''re linking to your files incorrectly.

Throughout your solution you need to consistently link to locations in your own directoy structure. If you''re never going to move your project you can always set the href attribute to

<a href="/myproject/mypage.html">Example</a>


Y ou在这里必须意识到,路径开头的/意味着浏览器将查找网站的根目录.因此,无论您在哪个页面上,对于 example.com/this/is/my/app/index.html 此页面上任何指定


You have to realize here that the / in the beginning of the path means the browser will look to the root of the website. So no matter what page you''re on, for example.com/this/is/my/app/index.html any link on this page that specifies

<a href="/myproject/mypage.html">Example</a>

将始终指向 example.com/myproject/mypage.html

Y ou像这样指定当前目录

will always point to example.com/myproject/mypage.html

You specify the current directory like so

<a href="myproject/mypage.html">Example</a>

这将指向 example.com/this /is/my/app/myproject/mypage.html (当用户位于 example.com/this/is/my/app/index.html
上)
/开头的 S o链接是绝对的,如果您省略开头的/链接是相对于当前站点的链接,则它们链接到当前站点的根目录.当前路径.

Y ou还可以指定

this will point to example.com/this/is/my/app/myproject/mypage.html when the user is on example.com/this/is/my/app/index.html

So links starting with / are absolute and they link to the root of the current site if you omit the beginning / your link is relative to the current path.

You can also specify

<a href="./myproject/mypage.html">Example</a>

指向当前目录.

A 您还可以指定

to point to the current directory.

Additionally you can specify

<a href="../myproject/mypage.html">Example</a>

,这会将您上移一个目录.因此,页面 example.com/directory/index.html 上方的链接将指向 example.com/myproject/mypage.html .

K 请记住,您可以将../和一个或多个../组合在一起以向上移动多个目录.

T 他的

this will move you up one directory. So the link above on the page example.com/directory/index.html will point to example.com/myproject/mypage.html.

Keep in mind that you can combine ../ with one or more ../ to move up more than one directory.

This

<a href="../../myproject/mypage.html">Example</a>

完全有效,它将使您上移两个目录.

想进一步说明这一点.当您看到地址 example.com/article.html?id=101 时,这会将名为id的 GET 变量(其值为101)传递给根目录中的article.html. Web服务器的目录.您可以在目录索引上使用 GET vars.目录索引是未指定文件时服务器提供的默认文件.因此, example.com 在请求时,服务器将加载默认文件(通常为index或默认.php或.htm或.aspx或其他文件).因此,链接example.com?id=101会将名称为id且值为101的 GET 变量传递给 example.com 的目录索引.

is totally valid and will move you up two directories.

I want to take this a little further. When you see an address example.com/article.html?id=101 this is passing a GET variable named id with the value 101 to article.html residing on the root directory of the webserver. You can use GET vars on a directory index. A directory index is a default file that''s served by the server when no file is specified. So example.com when requested the server will load the default file generally index or default .php or .htm or .aspx or whatever. So the link example.com?id=101 passes a GET variable with the name id and value 101 to the directory index of example.com.


这篇关于服务器上运行的href标签错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆