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.
    • 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
                        • Where to put 301 redirects in my Wordpress htaccess file?
                          Benspain
                          Benspain
                          0
                          3
                          34

                        • Search Console rejecting XML sitemap files as HTML files, despite them being XML
                          SearchDeploy
                          SearchDeploy
                          0
                          5
                          89

                        • Htaccess file help
                          DirkC
                          DirkC
                          0
                          4
                          120

                        • Help creating a 301 redirect in my htaccess file
                          Felip3
                          Felip3
                          0
                          4
                          108

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

                        • 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

                        • .htaccess file in wordpress blog
                          seoug_2005
                          seoug_2005
                          0
                          5
                          449

                        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