在 url 后添加尾部斜杠会将框移动到菜单下方上面有标志

发布于 2024-08-23 13:48:36 字数 638 浏览 8 评论 0原文

我正在使用代码点火器。

我的产品页面显示了我们拥有的所有产品,然后用户可以单击每个产品名称以获取有关该特定产品的更多详细信息。因此,我已将 products 声明为类,并将 Product_name 声明为产品类中的函数 - 这样我就可以获得 url www.company.com/products/product_name。

当我访问 www.company.com/products 时,一切都很好,但如果我添加尾部斜杠,那么它看起来像 www.company.com/products/ 我的窗口位于徽标下方,菜单在其上方移动隐藏徽标和菜单。当我访问 www.company.com/products/product_name 时,也会发生同样的情况。

当我添加尾部斜杠或转到“product_name”页面时,如何确保下面的窗口不会隐藏。

任何帮助将不胜感激。

I am using codeigniter.

My products page shows all the products we have and then users can click on each product_name to get more details about that particular product. So, I have declared products as the class and product_name as a function within the product class - so I could get the url www.company.com/products/product_name.

When I go to www.company.com/products everything is fine but if I add a trailing slash so it looks like www.company.com/products/ my window underneath the logo and menu moves over it hiding both the logo and menu. The same happens when I go to www.company.com/products/product_name.

How can I make sure that the window below does not hide when I add trailing slashes or when I go to product_name pages.

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城花音 2024-08-30 13:48:37

问题是您已经为图像指定了相对路径。您需要使它们绝对,或者至少相对于当前位置。也就是说,如果您将图像路径从: 更改

<img src="images/obsia.png">

<img src="/images/obsia.png">
or
<img src="http://www.obsia.com/images/obsia.png">

您的问题将得到解决。

发生这种情况的原因是图像的路径是由基本 URL 确定的。当您访问 http://www.obsia.comhttp://www.obsia.com/products 时,您的基本 URL 为 http:// /www.obsia.com

对于浏览器,images/obsia.png 将呈现为 http://www.obsia.com/image/obsia.png,您的服务器将其解释为 wwwroot/images/obsia.png 和相关链接有效。

但是,如果您这样做 http://www.obsia.com/products/ 您的基本网址为 http://www.obsia.com/products 且相对路径您的图像从 http://www.obsia.com/images/obsia.png 更改为 http://www.obsia.com/products/images/obsia.png.
您的服务器将此解释为 ,您的服务器将其解释为 wwwroot/images/products/obsia.png,这不是有效路径。服务器返回 404——导致图像损坏。

如果您使用 Firebug 的 .Net 面板,您可以看到这一点。对您的徽标的请求返回:

GET obsia.png
http://www.obsia.com/products/images/obsia.png

404 Not Found

obsia.com

539 B

The problem is that you have specified a relative path for your images. You need to make them absolute, or at least relative to the current location. That is to say, if you change your image path from:

<img src="images/obsia.png">

to

<img src="/images/obsia.png">
or
<img src="http://www.obsia.com/images/obsia.png">

Your problem will be solved.

The reason this is happening is because the path to the images is determined by the base URL. When you are at http://www.obsia.com or http://www.obsia.com/products, your base URL is http://www.obsia.com.

To the browser then images/obsia.png is rendered as http://www.obsia.com/image/obsia.png, which your server interprets as wwwroot/images/obsia.png and the relative link works.

However, if you do http://www.obsia.com/products/ your base url is http://www.obsia.com/products and the relative path for your images changes from http://www.obsia.com/images/obsia.png to http://www.obsia.com/products/images/obsia.png.
Your server interprets this as , which your server interprets as wwwroot/images/products/obsia.png, which is not a valid path. The server returns a 404 --resulting in broken images.

You can see this if you use Firebug's .Net panel. The request for your logo returns:

GET obsia.png
http://www.obsia.com/products/images/obsia.png

404 Not Found

obsia.com

539 B
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文