Weird: /?name in URL leads to blog

Those are reserved keywords

When you visit a WordPress blog you have:

blogindexpage/?queryvariables=queryvalues

So for a search request:

example.com/?s=searchterm

For a post/page of ID 12:

example.com/?p=12

etc etc

Pretty permalinks hides all this by using regular expressions to map nice looking URLs on to their equivalents. This doesn’t prevent someone from still doing that though, e.g.

tomjn.com/?s=query_posts

Will still search my website for ‘query_posts’, even though I’ve added pretty permalinks.

The same is true of all the query variables listed under the WP_Query documentation. These variables are added to the query WordPress runs, and the template chosen and the posts loaded are dependent on those query variables

So how Do I Fix My Issue?

Don’t use reserved keywords and query variables to name your post variables. Or better yet, use POST rather than GET to submit your forms, especially where emails and submissions are concerned ( imagine if I visited that page and refreshed 20 times or had it open in my tabs and closed and reopened my browser over several days? )

Since you’ve stated you can’t change from ‘name’, I advise you instead add something similar to this to your htaccess:

RewriteCond %{QUERY_STRING} (.+?)&name=(.+)
RewriteRule ^thank-you/ /thank-you/?%1&fullname=%2 [R,NC,L]

As described here, this will rewrite the ‘name’ into a ‘fullname’ GET argument.

Leave a Comment