阿帕奇重写URL创建链接问题 [英] Apache Rewrite URL Creating Linking Issues

查看:130
本文介绍了阿帕奇重写URL创建链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:重写URL导致一些链接中断

Problem: rewrite url causing some links to break.

的.htaccess具有如下的规则:

重写规则^博客/([0-9] +)/ [ - 0-9A-ZA-Z] + $的index.php行动=博客&放大器; =帖子ID $ 1 \\%23disqus_thread [NC]

RewriteRule ^blog/([0-9]+)/[-0-9a-zA-Z]+$ index.php?action=blog&postID=$1\%23disqus_thread [NC]

在头模板的样式表的参考:

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

我可以点击:

domain.com/blog/1/title-of-article,并获得该文件就好了,但样式表链接断裂

domain.com/blog/1/title-of-article and get to the file just fine, but style sheet link breaks

如果我直接去:

domain.com/index.php?action=blog&postID=1#.UYV1mcqRiSo那么样式表加载罚款的(忽略#.UYV1mcqRiSo,也就是从Disqus code)的。

domain.com/index.php?action=blog&postID=1#.UYV1mcqRiSo then the style sheet loads fine (ignore #.UYV1mcqRiSo, that is code from Disqus).

这也打破了我的标志的链接,这是:

This is also breaking my logo link, which is:

<a href="./">

而不是带我去domain.com的,它会domain.com/blog/1~~V /

Instead of taking me to domain.com, it's going to domain.com/blog/1/

我的基本文件结构是:

index.php文件的style.css并在根,加载了viewPost.php在/模板文件夹。

index.php and style.css is in root, which loads up viewPost.php in/templates folder.

这是怎么回事,如何纠正呢?

What is going and how do I correct this?

推荐答案

最简单的办法:只需设置相对于域根的链接,通过用斜线(RESP面向他们删除的点指的是当前文件夹中的链接。 ):

Easiest solution: Just set your links relative to the domain root, by fronting them with a slash (resp. removing the dot referring to the current folder in the link):

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

这篇关于阿帕奇重写URL创建链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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