WordPress.org

Ready to get started?Download WordPress

Forums

Quick Page/Post Redirect Plugin
[resolved] Redirect with wildcard support for variable in url? (2 posts)

  1. pakistan1
    Member
    Posted 10 months ago #

    I have the following use case:

    I have an incoming link (over which I have no control) that comes with some parameters:

    example.com/slug.html?variable1=somevalue&variable2=somevalue

    Problem is, the variables are variable (no pun intended), so that I would like to match /slug.html and whatever comes after to redirect to a page /slug/. Transferring the variables to the new URL is a plus, but I could live without it.

    Is there any wildcard support or 'ignore whatever comes after a question mark' already built into the plugin?

    http://wordpress.org/plugins/quick-pagepost-redirect-plugin/

  2. prophecy2040
    Member
    Plugin Author

    Posted 10 months ago #

    The plugin does not have a wild card feature. It is designed for simple redirects, so it was intentionally left out.

    This is one of the cases where you would want to use something like .htaccess. A simple bit of code should work fine.

    The .htaccess file is in the root folder of your site (where the wp-config .php file is located). If you do not know how to edit your .htaccess file, search on Google, use a plugin like http://wordpress.org/plugins/wp-htaccess-control/screenshots/ or read something like this tutorial http://www.shoutmeloud.com/how-to-edit-your-wordpress-htaccess-file.html.

    I also want to point out that editing the htaccess file is at your own risk. It is the easiest way to achieve what you want to do, but doing it wrong can make your site not load - so be careful!

    Add this to the .htaccess file BEFORE any WordPress stuff you see like, # BEGIN WordPress:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    Redirect 301 /slug.html /slug/
    </IfModule>

    Change the word slug to the file name and the slug you will need changed. You can change 301 to 302 if you only want to return a temporary redirect response. That should redirect and keep the Query String data attached.

    Regards,
    Don

Reply

You must log in to post.

About this Plugin

About this Topic