Redirect url for public page in wordpress?

I am working on this site developed in WordPress 3.3.1. My client wanted me to develop a public page. This page will be a simple php page. It will reside in wordpress directory but will not be a part of CMS itself. The issue here is that I want a url redirection for this page. My client wants to send a link in email to members of the website, so he wants to keep the url clean.

This is the format of current url that he wants to send to the members:

Read More

‘http://www.example.com/shop/”url_encoded_category_name”/product/”product_id”‘

And I want to redirect it to:

‘http://www.example.com/template-public-home?productId=”product_id”‘

I was rewriting the url for now. But as you can see in the first url format that “url_encoded_category_name” and “product_id” are variables and therefor rewriting would mean that I am trying to rewrite different urls to same url(only query string changes). I want to change it to redirection because as I understand this approach of rewriting multiple urls to the same url is penalized by most of the search engines.

For rewriting I edited the .htaccess file.
What I wanted to ask is that considering that I have a publicly accessible page within wordpress directory:

  1. what is the most suitable way to redirect my url?
  2. In my case what is a better Code? 301 or 302?

Thanks for any assistance you can provide or direct me to a source where I could learn about it.

Related posts

Leave a Reply

1 comment

  1. First of all, if your client just wants to use the generated URL in emails to members, no search engine will ever know. However, if there is a chance that they leak you might indeed end up with duplicate content. Redirection then is the correct approach.

    1. You can redirect just as you rewrite by using the [R] flag in your rule (usually in conjunction with L as [R,L] so that the rules below that match are not executed.
    2. From the point of view of a search engine (and a user as well), these are permanent redirects – you will never ever use the URL in the email as a primary URL (or will you?). That means you should use R=301.

    Take a look at the documentation to learn about the flags, test your rewrite rules online here and check https://stackoverflow.com/questions/1426056/good-htaccess-mod-rewrite-url-rewriting-tutorial for some hands-on material.