Viewing 5 replies - 1 through 5 (of 5 total)
  • It sounds like you’re using .htaccess to create your redirect rule for the URL. If that’s the case, here’s a thread on how to create a rule that doesn’t change the URL: https://stackoverflow.com/questions/14928498/htaccess-url-masking-instead-of-redirecting

    That being said, this is outside of the scope of support for these forums, since this kind of thing is not a part of WordPress core, so you will need to contact your web host for further assistance.

    If you are using a plugin to create the redirects, then you will need to contact the developer of the plugin.

    Thread Starter rashuan

    (@rashuan)

    Thank you for the reply. I’ve tried doing everything with htaccess, but found out that WP Rewrite API is a better way. But using the add_rewrite_rule, I get the standard redirect with the link change. I thought that there might be some parameter or smth to keep the old link.

    Ah, I see. I’m not super familiar with the Rewrite API, but this Stack Exchange thread looks like it might have the answer: https://wordpress.stackexchange.com/questions/44117/keep-requested-entered-url-with-add-rewrite-rule

    Thread Starter rashuan

    (@rashuan)

    Thanks. I’ll write down the solution once it works.

    Thread Starter rashuan

    (@rashuan)

    Looks like the add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?pagename=somepage&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]','top'); code was the way to go. Although I still couldn’t retrieve the GET part. So what I did was:

    1.) In the functions.php I’ve added a new rewrite rule as an init action:
    add_rewrite_rule(‘^hotels/([^/]*)/([^/]*)/([^/]*)-([0-9]*)/?’,’index.php?pagename=hotels’,’top’);
    2.) Since I couldn’t get the other GET parameters to work, I’ve just read the $_SERVER[‘REQUEST_URI’] from the plugin part and made appropriate checks of the ID from the URI.

    It does create quite a bunch of potential alternative links that would create issues with SEO. So, I’ll need to ensure that any alternating links that have same ID would be redirected to the original page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Creating custom URLs for one page’ is closed to new replies.