在 url 后添加尾部斜杠会将框移动到菜单下方上面有标志
我正在使用代码点火器。
我的产品页面显示了我们拥有的所有产品,然后用户可以单击每个产品名称以获取有关该特定产品的更多详细信息。因此,我已将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您已经为图像指定了相对路径。您需要使它们绝对,或者至少相对于当前位置。也就是说,如果您将图像路径从: 更改
为
您的问题将得到解决。
发生这种情况的原因是图像的路径是由基本 URL 确定的。当您访问
http://www.obsia.com
或http://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 面板,您可以看到这一点。对您的徽标的请求返回:
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:
to
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
orhttp://www.obsia.com/products
, your base URL ishttp://www.obsia.com
.To the browser then
images/obsia.png
is rendered ashttp://www.obsia.com/image/obsia.png
, which your server interprets aswwwroot/images/obsia.png
and the relative link works.However, if you do
http://www.obsia.com/products/
your base url ishttp://www.obsia.com/products
and the relative path for your images changes fromhttp://www.obsia.com/images/obsia.png
tohttp://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: