开发者

Redirect/block WordPress URLs with the /?p=x structure. Eg. site.com/?p=2

I'm building a site with hashed permalinks so I can email a test.com/aedoiu2348791lkd style URL to a client. It's to provide a level of privacy without the need to log in or dick around with passwords.

Unfortunately, WordPress redirects any URL with the ?p=x url structure:

so mysite.com/?p=2 redirects to mysite.com/about


Obviously, the hashed URL is pretty useless when someone can run through /?p=xx and see every post and page I've ever made.

Is there a way to stop WordPress from redirecting this type of link and either throwing a 404 or redirecting to the homepage?

I only want the page to be accessible from the "proper"开发者_运维技巧 mysite.com/asdfghj-page style of URL.


Solution ...sort of
Added to top of .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} /?p=(\d*)
RewriteRule ^$ *? [R=404,L]
</IfModule>

I don't really get it... but this works. Ideally it would redirect to the wordpress 404 page, however.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜