Forums

Adjust a URL (4 posts)

  1. petrosweb
    Member
    Posted 3 months ago #

    Hallo all,

    first of all, sorry for my English! :)

    I have a URL in this form: http://www.something.com/translator/?word=Hallo
    and i need it to be in this form: http://www.something.com/translator/Hallo

    i take the variable value 'word' from an input in my home page and i send it to a page named 'translator'

    any one knows how to get the URL in this form?
    (http://www.something.com/translator/Hallo)

  2. peredur
    Member
    Posted 3 months ago #

    What are your permalink settings?

    Cheers

    PAE

  3. petrosweb
    Member
    Posted 3 months ago #

    i have set the permalink to custom structure: /%postname%/

  4. petrosweb
    Member
    Posted 3 months ago #

    i have found the following code to rewrite the URL but i cant make it work. Any one knows whatg am i doing wrong?

    thanks..

    <code>
    add_action( 'init', 'ss_permalinks' );
    function ss_permalinks() {
        add_rewrite_rule(
            'translator/([^/]+)/?',
            'index.php?pagename=translator&service=$matches[1]',
            'top'
    );
    }
    add_filter( 'query_vars', 'ss_query_vars' );
    function ss_query_vars( $query_vars ) {
        $query_vars[] = 'wordid';
        return $query_vars;
    }
    </code>

Reply

You must log in to post.

About this Topic

Tags