URL重写问题未加载.css [英] URL rewrite issue not loading .css

查看:86
本文介绍了URL重写问题未加载.css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将旧站点移植到新模板,并且Windows 2008重写模块遇到了问题.我要重写的链接看起来像这样:

I'm porting an old site to a new template and am having problems with the Windows 2008 rewrite module. The link I'm trying to rewrite looks like this:

http://ltweb2008.serveronline.net/product.php?pID=75

并打开页面就好了.然后,我应用新的URL并加载正确的内容,但不再加载模板的style.css 文件.

and brings up the page just fine. Then I apply the new URL and it loads the proper content, but doesn't load the template's style.css file anymore.

http://ltweb2008.serveronline.net/product/75/any-text-here

问题似乎是制作模板(画布)的公司将主.css文件放在根目录中,而其余所有文件都加载到了/css中.现在,我无法使用 rewrite 来加载主.css文件,当我将其移至/css时,它仅显示空白页,尽管查看页面源代码.

The problem seems to be that the company who made the template (canvas) put the main .css file in the root directory, but loaded all the rest in /css. Now I can't get the main .css file to load using the rewrite and when I move it down to /css it only displays a blank page, though when I check out the page source it's all there.

此页面显示但不使用style.css(带有重写):

With this the page shows but is not using style.css (with rewrite):

<link rel="stylesheet" href="style.css" type="text/css" />

对于任何这些页面,该页面完全空白(带有重写):

With any of these the page is completely blank (with rewrite):

  1. <link rel="stylesheet" href="/style.css" type="text/css" />
  2. <link rel="stylesheet" href="/css/style.css" type="text/css" />
  3. <link rel="stylesheet" href="http://ltweb2008.serveronline.net/style.css" type="text/css" />
  1. <link rel="stylesheet" href="/style.css" type="text/css" /> OR
  2. <link rel="stylesheet" href="/css/style.css" type="text/css" /> OR
  3. <link rel="stylesheet" href="http://ltweb2008.serveronline.net/style.css" type="text/css" />

我正在将其用于模式:

^product/([0-9]+)/([^/]+)$

和重写URL:

/product.php?pID={R:1}

有人知道我想念什么吗?

Does anyone know what I'm missing?

推荐答案

一种解决方案是使用绝对路径(例如/css或/js,而不仅仅是css//js,但这似乎不是一个可靠的解决方案,因为我们必须在所有文件上进行更改,

one solution is that use absolute path (ex /css, or /js rather than just css/, /js but this is not looks a reliable solution since we've to change it on all files,

这是因为您的相对URI的基数已更改.最初,当页面为/product.php?id=75时,基数为/,并且浏览器使用/基数正确填充了相对链接.但是,当浏览器转到/product/75/any-text-here之类的页面时,基准突然变为/product/,并尝试将其附加在所有相对URL的前面,因此没有一个加载.

This is because your relative URIs have their base changed. Originally, the base is / when the page is /product.php?id=75, and the browser properly fills in relative links with the / base. But when the browser goes to a page like /product/75/any-text-here the base suddenly becomes /product/ and it tries to append that in front of all relative URLs and thus none of them load.

您可以将链接设为绝对,也可以更改页面标题(在<head> </head>标记之间)的URI基:

You can either make your links absolute, or change the URI base in the header of your pages (inbetween the <head> </head> tags):

<base href="/">

这篇关于URL重写问题未加载.css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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