很简单的mod_rewrite问题 [英] Very simple mod_rewrite questions

查看:144
本文介绍了很简单的mod_rewrite问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1的mod_rewrite是否意味着,如果我做这个网址:

  domain.com/ad.php?id=8498292
 

INTO

  domain.com/8498292
 

这是我的网站上所有的链接都必须改到后来上面?

例如链接: domain.com/ad.php?id=8498292 不会现在的工作,除非我将其替换为 domain.com/ 8498292 ? 或者将服务器知道它们是相同的还是?

2 - 将重写链路出现改写浏览器联系地址栏还,所以如果我输入 domain.com/ad.php?id=8498292 这实际上将出现为 domain.com/8498292 在地址栏中本身?

3请问图像,其链接被改写完好无损地保留在网页上的所有其他相关的链接和材料?如将图片和链接仍然工作在这个页面这是相对的?

感谢

解决方案
  1. 您可以编写规则,这样既会工作,但通常你需要的链接,在干净的格式,当搜索引擎索引你的网页。

  2. 的mod_rewrite可以做一个内部的重写,如果页面是在同一个域。人们必须使用 [R] 标记,强制外部重定向,如果这是需要的。

  3. 您可以制定规则的膨胀或者为受限制的必要,以避免重写媒体的URL。 的RewriteCond 有多种方法来测试重写的可行性。

1- Does mod_rewrite means that if I make this url:

  domain.com/ad.php?id=8498292

INTO

  domain.com/8498292

that all links on my website will have to be changed to the later above?

example the link: domain.com/ad.php?id=8498292 wont work now, unless I replace it with domain.com/8498292 ? Or will the server know that they are the same still?

2- Will the rewritten link appear rewritten in the browsers adress bars also, so if I enter domain.com/ad.php?id=8498292 it will actually appear as domain.com/8498292 in the adress bar itself?

3- Will images and all other related links and material on the page whose link is rewritten remain intact? ie will pictures and links still work FROM that page which are relative?

Thanks

解决方案

  1. You can write the rules such that both will work, but generally you'll want the links to be in the "clean" format for when search engines index your pages.

  2. mod_rewrite can do an internal rewrite if the pages are on the same domain. One would have to use the [R] flag to force an external redirect if that was desired.

  3. You can make the rules as expansive or as restricted as necessary in order to avoid rewriting media URLs. RewriteCond has a number of ways to test the viability of rewriting.

这篇关于很简单的mod_rewrite问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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