Redirect wordpress page with variable

Just created a website based on WordPress and now I have the following problem. The old site which wasn’t build in WordPress used the variable p= for its pages just like WordPress. Now I’m trying to redirect them but that doesn’t work, I think because WordPress also uses the p variable.

I want to redirect the page http://purplethinking.nl/mauritshof/?p=brunch to the page http://purplethinking.nl/mauritshof/feestelijk/brunch

Read More

I changed my .htaccess and added the following line:

RewriteRule ^/mauritshof/?p=brunch$ /feestelijk/brunch/[L]

Could you tell what I’m doing wrong?

Edit: Here is my complete .htaccess file

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mauritshof/

RewriteCond %{QUERY_STRING} ^p=([^&]+)
RewriteRule ^mauritshof/?$ /feestelijk/brunch/ [L,R]

RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mauritshof/index.php [L]
</IfModule>

# END WordPress

Related posts

Leave a Reply

1 comment

  1. Your rule cannot work because:

    • RewriteRule doesn’t match QUERY_STRING.
    • RewriteRule doesn’t match leading slash
    • You need a R flag for redirect

    Full .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /mauritshof/
    
    RewriteCond %{QUERY_STRING} ^p=(brunch)(?:&|$)
    RewriteRule ^/?$ /feestelijk/%1/? [L,R]
    
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /mauritshof/index.php [L]
    </IfModule>
    
    # END WordPress