How to pass url as a parameter in a add_rewrite_rule

I am building a plugin which relies on passing the url as a GET parameter. Now, I am trying to prettify the links by using rewrite rules but am stuck.

What I have now:

Read More
function oe_wpib_add_rewrite_rules() {

    add_rewrite_tag( '%wpib%','^(http(?:s)?://[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*.[a-zA-Z]{2,6}(?:/?|(?:/[w-]+)*)(?:/?|/w+.[a-zA-Z]{2,4}(?:?[w]+=[w-]+)?)?(?:&[w]+=[w-]+)*)$' );
    add_rewrite_rule( '^wpib/([^&]*)', 'index.php?wpib=$matches[1]', 'top' );

}

add_action( 'init', 'oe_wpib_add_rewrite_rules' );

What above does is recognizes

http://domain.com/wpib/somestring 

and translates it to a

http://domain.com/?wpib=somestring

The problem is that when I pass the url like this:

http://domain.com/wpib/http://google.com

I get this as the query value:

http://domain.com/wpib/http:/google.com

So basically, one slash is missing.

Can you help me out here, as I am lost, first time doing rewrites so would appreciate any guidance.

Related posts

Leave a Reply