The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Converting files from .html to .php or editing .htaccess file

    Converting files from .html to .php or editing .htaccess file

    Technical SEO Issues
    11 7 3.6k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JohnHerrigel
      JohnHerrigel last edited by

      Good day all,

      I have a bunch of files that are .html and I want to add some .php to them.

      It seems my 2 options are

      1. Convert .html to .php and 301 redirect

      or

      1. add this line of code to my .htaccess file and keep all files that are .html as .html

      AddType application/x-httpd-php .html

      My gut is that the 2nd way is better so as  not alter any SEO rankings, but wanted to see if anybody had any experience with this line of code in their .htaccess file as definitely don't wan to mess up my entire site 🙂

      Thanks for any help!

      John

      1 Reply Last reply Reply Quote 0
      • Highland
        Highland last edited by

        I would pick #2, where you process .html files with PHP. Changing URLs involves taking a temporary SEO hit and I would not recommend doing it.

        1 Reply Last reply Reply Quote 1
        • kdaly100
          kdaly100 last edited by

          Just make sure that you don't redirect all HTML files.  I suspect that either way is equal.  What you are telling in either case i

          "Hi Google we have moved but don't worry we have moved here"

          1 Reply Last reply Reply Quote 0
          • SteveGerencser
            SteveGerencser last edited by

            We use the AddType function all the time when updating websites. It's far easier to do that that to recreate everything and redirect it.

            It allows all of your internal navigation to remain as is and it keeps all of your inbound links from becoming redirected links. Also, remember that it has been announced that 301 redirected links lose value over time so this is another reason to not do it the hard way.

            1 Reply Last reply Reply Quote 0
            • jpgprinting
              jpgprinting last edited by

              I did option 1 on one of my websites some time ago and works fine, rankings are the same. Takes about 2 moth to get the same visits on all the links again.

              1 Reply Last reply Reply Quote 0
              • KeriMorgret
                KeriMorgret last edited by

                Have you considered just rewriting your URLs so they don't use extensions at all? That way, when you use a different technology, you don't need to rewrite your URLs once again. If you look at SEOmoz, you see they don't use .php or .html as extensions, but instead have no extensions.

                JohnHerrigel 1 Reply Last reply Reply Quote 0
                • JohnHerrigel
                  JohnHerrigel @KeriMorgret last edited by

                  This is a sweet idea.. any tutorial on this? How does it effect existing links directed at the .html and .php pages?

                  Thanks Keri!

                  Highland 1 Reply Last reply Reply Quote 0
                  • Highland
                    Highland @JohnHerrigel last edited by

                    If you really want to go this route, add this to your site .htaccess

                    RewriteCond %{SCRIPT_FILENAME} !-d
                    RewriteRule ^([^.]+)$ $1.html [NC,L]

                    So domain.com/file will access file.html

                    Again, the caveat is there is a short term SEO hit for doing this. Long term, you should be fine.

                    1 Reply Last reply Reply Quote 0
                    • donford
                      donford last edited by

                      Hi John,

                      If the URL's are well indexed and doing well, you "may" not want to change the url. To simply add the ability to run php first you can do it very easily with just what you thought, .htaccess

                      In fact when I took over as webmaster on my corporate site which was indexed very well I had to do just that.

                      Add this to your .htaccess file:

                      RemoveHandler .html .htm
                      AddType application/x-httpd-php .php .htm .html

                      JohnHerrigel 1 Reply Last reply Reply Quote 0
                      • JohnHerrigel
                        JohnHerrigel @donford last edited by

                        Thanks so much for this Don.. this is what I added that seemed to work for my server

                        AddHandler application/x-httpd-php .html .htm

                        As the AddType caused errors but doing  some further research I found the above code.

                        I wonder if what you propose would accomplish what I did?

                        Thanks and all the best,

                        John

                        1 Reply Last reply Reply Quote 1
                        • donford
                          donford last edited by

                          Hi John

                          The first line removes the extension

                          The second line adds them back in a specific order IE you want PHP to execute first.

                          If you got it going that is what counts.

                          Good luck,

                          Don

                          1 Reply Last reply Reply Quote 1
                          • 1 / 1
                          • First post
                            Last post
                          • Looking for a tool that will display the contents of the htaccess file
                            MikeTek
                            MikeTek
                            0
                            3
                            77

                          • Remove html file extension and 301 redirects
                            Tom-Anthony
                            Tom-Anthony
                            1
                            10
                            4.0k

                          • How can I find my Webmaster Tools HTML file?
                            healthgrades
                            healthgrades
                            0
                            5
                            309

                          • Kill your htaccess file, take the risk to learn a little
                            KevinBudzynski
                            KevinBudzynski
                            0
                            2
                            373

                          • How should I properly setup my .htaccess file?
                            maxduveen
                            maxduveen
                            0
                            5
                            2.0k

                          • Duplicate content problem from an index.php file
                            ocelot
                            ocelot
                            0
                            6
                            3.3k

                          • Need Help writing 301 redirects in .htaccess file
                            Dr-Pete
                            Dr-Pete
                            0
                            5
                            1.3k

                          • Help needed please with 301 redirects in htaccess file.
                            petersommertravels
                            petersommertravels
                            0
                            9
                            2.3k

                          Get started with Moz Pro!

                          Unlock the power of advanced SEO tools and data-driven insights.

                          Start my free trial
                          Products
                          • Moz Pro
                          • Moz Local
                          • Moz API
                          • Moz Data
                          • STAT
                          • Product Updates
                          Moz Solutions
                          • SMB Solutions
                          • Agency Solutions
                          • Enterprise Solutions
                          • Digital Marketers
                          Free SEO Tools
                          • Domain Authority Checker
                          • Link Explorer
                          • Keyword Explorer
                          • Competitive Research
                          • Brand Authority Checker
                          • Local Citation Checker
                          • MozBar Extension
                          • MozCast
                          Resources
                          • Blog
                          • SEO Learning Center
                          • Help Hub
                          • Beginner's Guide to SEO
                          • How-to Guides
                          • Moz Academy
                          • API Docs
                          About Moz
                          • About
                          • Team
                          • Careers
                          • Contact
                          Why Moz
                          • Case Studies
                          • Testimonials
                          Get Involved
                          • Become an Affiliate
                          • MozCon
                          • Webinars
                          • Practical Marketer Series
                          • MozPod
                          Connect with us

                          Contact the Help team

                          Join our newsletter
                          Moz logo
                          © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                          • Accessibility
                          • Terms of Use
                          • Privacy