5

I just published a completely revised version of a website (static site to a Wordpress powered one) without changing the domain or the web server. In the old site the URL structure was

  • example.com/product_category1.php
  • example.com/product1.php

and in the current one it is:

  • example.com/product_category1/
  • example.com/product_category1/product1/

so now it's more logical and without .php extensions.

Now, if I do a Google search e.g. for "product category 1", example.com/product_category1.php ranks higher than example.com/product_category1. I solved this by applying a 301 redirect from the GUI offered by my web hosting company, so now example.com/product_category1.php redirects to example.com/product_category1/. I noticed that I have to keep product_category1.php file in the public_html folder in order for the redirection to happen, otherwise the only redirection that happens is to the 404 page.

I'd like the example.com/product_category1.php and other .php extended URLs to vanish from the search results. Will they do so if they always get redirected, even though they still exist in the public_html folder? Is there a way to do the redirection without keeping the files? Or should this be dealt in a completely different manner in order to have maximum SEO and visibility for correct URLs in the new website?

  • Yes. A 301 redirect will tell the search engine to replace one page for another. After a period, you will be able to remove the redirects and let the pages 404. I would advise taking into account any back links before doing this to ensure that you preserve any value worth keeping. I would also work to include your product pages if you can. Cheers!! – closetnoc Jan 30 '17 at 23:34
3

...a 301 redirect from the GUI offered by my web hosting company ... I have to keep product_category1.php file in the public_html folder in order for the redirection to happen, otherwise the only redirection that happens is to the 404 page.

It sounds like the redirect has been implemented incorrectly (or rather, in the wrong place in your .htaccess file) by the hosting GUI. You should not need to keep the old .php files from which you are redirecting (although this makes no difference from an SEO point of view - it's being redirected).

It is a common problem with using a 3rd party tool (hosting GUI / cPanel for example) to implement redirects when you have an existing system in place. WordPress itself places directives in your .htaccess file (Apache per-directory config file) and the "hosting GUI" is probably doing the same when it implements the redirect. Without knowing exactly what your current directives are doing (which your "hosting GUI" probably does not) it is difficult to reliably make any "automatic" changes.

My guess is that the redirect directives have been placed after the existing WordPress directives by the "hosting GUI". Whereas they would need to be placed before the existing WP directives.

If the redirect directives are placed after the WP directives then they will only be processed if the file actually exists, because WP routes all non-existent files and processing stops there. But if the file doesn't exist then WP routes the URL and you get the 404, because the old URL is not a valid WP URL. This seems to be what is happening here.

If you add the contents of your /.htaccess file to your question then we can verify this.

Will they [vanish] if they always get redirected, even though they still exist in the public_html folder?

Yes. Eventually the old URLs will disappear from the SERPs if they are 301 redirected. From a search engine / end user point of view, it makes no difference whether the original file still exists or not. It is redirected, so they have no way of knowing.

Is there a way to do the redirection without keeping the files?

Yes, as mentioned above. It would only seem to be because of a conflict with existing directives that you are getting this seemingly bizarre behaviour. Taken out of context, you would get a puzzled look if you said to someone that the file needed to exist before you could redirect it!

Or should this be dealt in a completely different manner in order to have maximum SEO and visibility for correct URLs in the new website?

A 301 redirect is all that's required. However, it should have been implemented in the very beginning, as soon as the URLs changed, in order to have had "maximum SEO".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.