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
-
HTML Encoding Error
Okay, so this is driving me nuts because I should know how to find and fix this but for the life of me cannot. One of the sites I work for has a long-standing crawl error in Google WMT tools for the URL /a%3E that appears on nearly every page of the site. I know that a%3E is an improperly encoded > but I can't seem to find where exactly in the code its coming from. So I keep putting it off and coming back to it every week or two only to wrack my brain and give up on it after about an hour (since its not a priority and its not really hurting anything). The site in question is https://www.deckanddockboxes.com/ and some of the pages it can be found on are /small-trash-can.html, /Dock-Step-Storage-Bin.html, and /Standard-Dock-Box-Maxi.html (among others). I figured it was about time to ask for another set of eyes to look at this for me. Any help would be greatly appreciated. Thanks!
Technical SEO | | MikeRoberts0 -
Free Joomla SEO Extension?
Hi all -- all along, I have used Tag Meta as a super simple Joomla extension to manage page titles. The most recent Joomla site I manage is using K2. The Tag Meta extension will install, but something with K2 is overriding the page titles that I put in. Thus, I am simply looking for a free (if at all possible) Joomla extension that will allow me to enter unique page titles for each page of the site without changing the Joomla page title of each page. Or, if anyone has had the same problem, I'm looking for a solution to make Tag Meta and K2 play nice. Any suggestions?
Technical SEO | | Bandicoot0 -
Changed URLs from Upper to Lower Case, and lost page authority should we switch back?
During an overhaul of our site architecture we switched from having capitals in our urls to all lower case, we did the 301's but the page authority is not nearly what it was should we switch back? (new) http://www.usleaseoption.com/rent-to-own/florida vs (old) http://www.usleaseoption.com/rent-to-own/Florida/
Technical SEO | | mjo1360 -
Can changing a host provider impact search rankings?
I was wondering if changing my host provider would impact my search rankings on the major search engines?
Technical SEO | | bronxpad0 -
Site description on Google has changed to a very outdated description
When I googled my top keyword today, my site on google showed a description of my site from YEARS ago. It is completely irrevelant and misleading to visitors. Why would this have happened and is there anything I can do about it? Thanks!!! Betsy
Technical SEO | | bhsiao0 -
Why sudden change in rankings?
I have been working on a domain for site which has only been up for a few months. I have mainly been working on building trust and authority for the site, with only a few links to my keyword phrases, which I was saving for the end, and concentrating on good quality non-spammy type links. It was progressing nicely until last weekend when I went from the first page on Google to the 3rd and 4th pages. Was there some kind of update?
Technical SEO | | waynekolenchuk0 -
Converse.com - flash and html version of site... bad idea?
I have a questions regarding Converse.com. I realize this ecommerce site is needs a lot of seo help. There’s plenty of obvious low hanging seo fruit. On a high level, I see a very large SEO issue with the site architecture. The site is a full page flash experience that uses a # in the URL. The search engines pretty much see every flash page as the home page. To help with issue a HTML version of the site was created. Google crawls the Home Page - Converse.com http://www.converse.com Marimekko category page (flash version) http://www.converse.com/#/products/featured/marimekko Marimekko category page (html version, need to have flash disabled) http://www.converse.com/products/featured/marimekko Here is the example of the issue. This site has a great post featuring Helen Marimekko shoes http://www.coolmompicks.com/2011/03/finnish_foot_prints.php The post links to the flash Marimekko catagory page (http://www.converse.com/#/products/featured/marimekko) as I would expect (ninety something percent of visitors to converse.com have the required flash plug in). So the flash page is getting the link back juice. But the flash page is invisible to google. When I search for “converse marimekko” in google, the marimekko landing page is not in the top 500 results. So I then searched for “converse.com marimekko” and see the HTML version of the landing page listed as the 4<sup>th</sup> organic result. The result has the html version of the page. When I click the link I get redirected to the flash Marimekko category page but if I do not have flash I go to the html category page. ----- Marimekko - Converse All Star Marimekko Price: $85, Jack Purcell Helen Marimekko Price: $75 ... www.converse.com/products/featured/marimekko - Cached So my issues are… Is converse skating on thin SEO ice by having a HTML and flash version of their site/product pages? Do you think it’s a huge drag on seo rankings to have a large % of back links linking to flash pages when google is crawling the html pages? Any recommendations on to what to do about this? Thanks, SEOsurfer
Technical SEO | | seosurfer-2883190 -
Existing Pages in Google Index and Changing URLs
Hi!! I am launching a newly recoded site this week and had a another noobie question. The URL structure has changed slightly and I have installed a 301 redirect to take care of that. I am wondering how Google will handle my "old" pages? Will they just fall out of the index? Or does the 301 redirect tell Google to rewrite the URLs in the index? I am just concerned I may see an "old" page and a "new" page with the same content in the index. Just want to make sure I have covered all my bases. Thanks!! Lynn
Technical SEO | | hiphound0