【问题标题】:Redirect dirty urls to a clean url将脏网址重定向到干净的网址
【发布时间】:2016-04-25 20:04:08
【问题描述】:

好的,所以我已经完成了清理我的 url 的过程,一切都很顺利,我将以下内容放在我的 htaccess 中。

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /l/index.php?mp3=$1&img=http://www.dailynewsounds.com/wp-content/uploads/2016/01/tinashe-5535799554a1b-3.jpg&g=R\%26amp\%3BB&p=8\%20hours\%20ago&s=+Energy&a=Tinashe+Ft.+Juicy+J+ [L]

这可以改变我的网址,但我们有我们讨厌的网址指向页面。

http://dl.example.com/l/index.php?mp3=oo8aey7qw3n9&img=http://www.example.com/wp-content/uploads/2016/01/stuey-rock-ft-sy-ari-da-kid-569e83c69cf5e.jpeg&g=R%26amp%3BB&p=10%20hours%20ago&s=+Me+And+You&a=Stuey+Rock+Ft.+Sy+Ari+Da+Kid+

我怎样才能检查我的网址以查看它是否包含index.php 以及是否将其重定向到新页面?

【问题讨论】:

  • 新页面会是什么?
  • @hjpotter92 example.com/193812412.html
  • 那么,基本上是为mp3参数传递的值?

标签: .htaccess mod-rewrite url-rewriting url-redirection friendly-url


【解决方案1】:

尝试以下规则:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /l/index\.php\?\S*mp3=\S* [NC]
RewriteCond %{QUERY_STRING} \bmp3=([^\s&]+) [NC]
RewriteRule ^ /%1.html? [R=301,L]

如果您使用的是 Apache 2.4.x,请将 L] 替换为 L,QSD]

【讨论】:

  • 当我使用这个http://dl.example.com/oo8aey7qw3n9.html?mp3=oo8aey7qw3n9&img=http://www.example.com/wp-content/uploads/2016/01/stuey-rock-ft-sy-ari-da-kid-569e83c69cf5e.jpeg&g=R%26amp%3BB&p=10%20hours%20ago&s=+Me+And+You&a=Stuey+Rock+Ft.+Sy+Ari+Da+Kid时它会返回一个url
猜你喜欢
  • 2011-06-25
  • 1970-01-01
  • 1970-01-01
  • 2018-10-18
  • 2021-02-17
  • 2012-10-21
  • 2013-06-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多