Php to html - change in extension
-
Hello, What is the code to redirect all the pages of a site from .php to .html extension? Thanks
-
I agree with you not to use any extension and will be looking for a code for this purpose.
-
Hello Zachary,
Where should i enter the line mentioned by you ? After the code provided by Daniel ?
Will it redirect all the external links ?
-
Thanks a lot daniel for your advice.
-
I'd suggest that if you can to not use any extension in the displayed URLs. That way the next time you change languages the URL won't change. As an example, see the SEOmoz URLs -- it's just http://www.seomoz.org/q/php-to-html-change-in-extension with no extension.
I don't know the code offhand for that, but I'm sure others can help you out with that.
-
Atul,
You definitely don't need to contact webmasters to change any links.
There is a 301 redirect flag you can apply to your rewrite rule:
RewriteRule ^(.*).html$ $1.php [R=301,L]
Do a 301 redirect test to confirm. Best of luck!
-
1. Yes since the code I gave you will rewrite the extension of every single page FROM php to html. From html to php would mean the same thing, since a link pointing to products.php would no longer work. The rewrite only rewrites the extensions and not the links.
2. Yes contacting the webmasters and changing the links would be better than doing 301 redirects of all your pages.
I advise to test this on a testing server first, especially if your site has a lot of pages.
-
Thanks Daniel.
"Remember you'll need to make sure to change all the links on your site, and all external links too."
1. Do you mean i will have to manually change all the internal links on the site ?
Shall i have to do this in the reverse case too ? For example changing html to php ?
2. For external links, should i contact the webmasters of the site linking to me ?
-
Add into your htaccess file :
RewriteEngine on
RewriteBase /
RewriteRule ^(.*).html$ $1.php [L]Remember you'll need to make sure to change all the links on your site, and all external links too.
The only other way around changing all the links would be to do 301 redirects for each URL which is, in my opinion not really worth all the work involved since .php and .html should both rank equally in Google and other search engines.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
How to recover search volume after domain name change?
On the 3rd of November we changed our company name and domain. The new site was not changed at all so the 301 process was quite straightforward. The change over was successful, no downtime, all pages redirected correctly (with a few minor exceptions). However, after a few days we started to see more and more links into the new site from the old site. They now stand at over 3 million. And links from the new site to the old site of over 200K. Links from the new site back to the old, were due to us having left a lot of links tucked away on various pages which were possibly causing loops with the 301 redirects on the old site. We fixed these and now there are no remaining links back to the old site, though we are still showing just over 200K links back to the old site. We are also seeing a LOT more back-links on the new site from old junk sites, which are not showing for the old site. A couple of years ago we went through about a year of trying to track down and remove thousands of spam backlinks. We did what we could, got a lot removed, showed Google the evidence, then Google lifted the penalty and said they had made some changes that meant the links were no longer causing the penalty. I added the old disavow file to the new site, but it doesn't cover a fraction of the sites which are being displayed as providing backlinks... many of which are clearly spammy. Is it possible that Google made some manual actions to lift the penalties but failed to associate these changes with the new domain? Changes that were not included in the disavow file? All help appreciated.
Technical SEO | | Exotissimo0 -
Changing a domain name, pages redirection
when changing a domain name, should we redirect all the pages to their new pages or only the indexed pages? Thanks
Technical SEO | | bigrat950 -
Changing URL - Ranking Disappeared?
Hi All, I named a page URL /plectrums/ within the back end framework. But then decided to change it to /personalised-plectrums/ I resubmitted a GWT sitemap and 301 redirected plectrums -> personalised-plectrums My ranking for personalised plectrums has disappeared and has not come back does anyone know why this is? Or is there something I have missed? Lewis
Technical SEO | | SO_UK0 -
What needs to be done to tell google my site has moved /changed
Hi everyone, I have a site, which I have re-built on a temporary domain, so that my main ecommerce site can still run.. I have noticed that google has already crawled my temporary domain. The only problem is I now want to transfer the new site back onto its proper domain (www.ourbrand.com). I have changed some of the URL structures of the new site so realize I will need to do re-directs relating to the same domain, but will google get confused that another domain used to have my new website on? I don't plan on using the old temporary domain again and wondered if I need to tell google in some way it was used just to build my site on? Michelle
Technical SEO | | nutjobshell0 -
Should I change hosting / registration when buying an established website?
I am buying an established website that is currently ranking very well for several keywords. I have no intentions of changing anything on the site. My question is, will it matter if I change where the site is hosted, and the whois information (I want to change it from public to private)? i.e., I don't want to do anything to mess up the current rankings of the site - will these changes have any effect? Thanks for the help.
Technical SEO | | red6marketing0 -
HTML Forms Dilute Pagerank?
Today, we have way too many links on our homepage. About 30 of them are add-to-basket links (regular html links) pointing to a separate application. This application 302 redirects the client back to the referring page. I have two questions: 1. Does the current implementation of our buttons dilute pagerank? Bear in mind the 302 redirect. 2. If the answer to the first question is yes, would transforming the buttons into form buttons change anything to the better? We would still 302 back to the referring page. I know Gbot follows GET forms and even POST forms, but does GBot pass on pagerank to the form URL?
Technical SEO | | TalkInThePark1 -
Worth Changing Redirect From 302 to 301?
Hi, I'm doing an audit on a site that had a redesign in Dec 2009. For some reason I looked to see what kind of redirects were used from the old pages to the current ones, and it looks like they used 302s, which obviously isn't ideal. Given that it's been so long and those pages have looong since been de-indexed, is it worth me suggesting that they change those old redirects to 301s? My thinking is that if those old pages were linked to externally then I should recommend it, but I can't find any link info on Linkscape/OSE, Majestic SEO or YSE. Any comments appreciated.
Technical SEO | | The_Heavies0 -
Site Change of Address - best method?
When changing domains, there's the obvious anxiety about sacrificing the value of your old domain. A client recently changed domains, immediately killed the old site (did everything properly with 301s, Webmaster Tools etc etc etc) and lost rankings completely for weeks. Turns out the site had been 'burnt' by the previous owner and it took a reconsideration request from Google before things recovered. Cost them rankings and cash with extra PPC spend. My question is: In order to avoid this potential hazard, what are your thoughts on submitting a change of address in Webmaster tools, but then leaving old site live for a few weeks to see how things pan out? I have never tried it and it seems to go against the grain, but interested to hear other people's experiences and how they have managed to change domain with minimal temporary damage. Thanks.
Technical SEO | | RiceMedia0