将脏网址重定向到一个干净的网址

问题描述:

好吧,我已经完成了清理网址的过程,并且一切都很顺利我把下面的内容放在我的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,如果它重定向到新的一页?

+0

新的页面会是? – hjpotter92

+0

@ hjpotter92 example.com/193812412.html – Ritzy

+0

那么,基本上是'mp3'参数的值? – hjpotter92

尝试以下规则:

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,QSD]更换L]

+0

当我使用这个'http://dl.example.com/oo8aey7qw3n9.html?mp3=oo8aey7qw3n9&img=http://www.example.com/wp-content/uploads/2016/它会返回一个网址01/stuey岩-FT-SY-ARI-DA-KID-569e83c69cf5e.jpeg&G = R%26安培%3BB&p = 10%20小时%20ago&S = +我+和+您&一个= Stuey +岩+英尺。+ SY +阿里+ Da + Kid' – Ritzy

+0

@Ritzy更新了回复 – hjpotter92