Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

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.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.