开发者

Rewrite URL - dynamic url stripping

I want to rewrite an url like this: http://www.piata-bi开发者_开发技巧o.ro/presa-bio.php?var1=http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHmU7U7bXtlH9Lo8dXfBs64PqxgbA&url=http://www.eva.ro/divertisment/stiri/un-nou-concept-de-magazin-articol-35491.html

to something like this : http://www.piata-bio.ro/presa-bio.php?var1=www.eva.ro/divertisment/stiri/un-nou-concept-de-magazin-articol-35491.html

Basically I want to strip to google news part and only remain with the final url (without the "http://").

I've been trying all sorts of solutions but nothing worked so far. FYI - I use wordpress

Any help would be greatly appreciated.

htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} url=(?:http://)?(.*)
RewriteRule presa-bio.php presa-bio.php?var1=%1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 # END WordPress


You can do it by matching the query string in a rewriteCond :

RewriteCond %{QUERY_STRING} url=(?:http://)?(.*)
RewriteRule presa-bio.php presa-bio.php?var1=%1 [L]

(If the ?: does not work with rewriteCond, loose it and use %2 instead of %1 in the next rule).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜