• milanzokovich-sh3jqL0l

        See all notifications

        Skip to content
        Moz logo Menu open Menu close
        • Products
          • Moz Pro
          • Moz Pro Home
          • Moz Local
          • Moz Local Home
          • STAT
          • Moz API
          • Moz API Home
          • Compare SEO Products
          • Moz Data
        • Free SEO Tools
          • Domain Analysis
          • Keyword Explorer
          • Link Explorer
          • Competitive Research
          • MozBar
          • More Free SEO Tools
        • Learn SEO
          • Beginner's Guide to SEO
          • SEO Learning Center
          • Moz Academy
          • MozCon
          • Webinars, Whitepapers, & Guides
        • Blog
        • Why Moz
          • Digital Marketers
          • Agency Solutions
          • Enterprise Solutions
          • Small Business Solutions
          • The Moz Story
          • New Releases
        • Log in
        • Log out
        • Products
          • Moz Pro

            Your all-in-one suite of SEO essentials.

          • Moz Local

            Raise your local SEO visibility with complete local SEO management.

          • STAT

            SERP tracking and analytics for enterprise SEO experts.

          • Moz API

            Power your SEO with our index of over 44 trillion links.

          • Compare SEO Products

            See which Moz SEO solution best meets your business needs.

          • Moz Data

            Power your SEO strategy & AI models with custom data solutions.

          Let your reputation grow with Reviews AI
          Moz Local

          Let your reputation grow with Reviews AI

          Learn more
        • Free SEO Tools
          • Domain Analysis

            Get top competitive SEO metrics like DA, top pages and more.

          • Keyword Explorer

            Find traffic-driving keywords with our 1.25 billion+ keyword index.

          • Link Explorer

            Explore over 40 trillion links for powerful backlink data.

          • Competitive Research

            Uncover valuable insights on your organic search competitors.

          • MozBar

            See top SEO metrics for free as you browse the web.

          • More Free SEO Tools

            Explore all the free SEO tools Moz has to offer.

          NEW Keyword Suggestions by Topic
          Moz Pro

          NEW Keyword Suggestions by Topic

          Learn more
        • Learn SEO
          • Beginner's Guide to SEO

            The #1 most popular introduction to SEO, trusted by millions.

          • SEO Learning Center

            Broaden your knowledge with SEO resources for all skill levels.

          • On-Demand Webinars

            Learn modern SEO best practices from industry experts.

          • How-To Guides

            Step-by-step guides to search success from the authority on SEO.

          • Moz Academy

            Upskill and get certified with on-demand courses & certifications.

          • MozCon

            Save on Early Bird tickets and join us in London or New York City

          Unlock flexible pricing & new endpoints
          Moz API

          Unlock flexible pricing & new endpoints

          Find your plan
        • Blog
        • Why Moz
          • Digital Marketers

            Simplify SEO tasks to save time and grow your traffic.

          • Small Business Solutions

            Uncover insights to make smarter marketing decisions in less time.

          • Agency Solutions

            Earn & keep valuable clients with unparalleled data & insights.

          • Enterprise Solutions

            Gain a competitive edge in the ever-changing world of search.

          • The Moz Story

            Moz was the first & remains the most trusted SEO company.

          • New Releases

            Get the scoop on the latest and greatest from Moz.

          Surface actionable competitive intel
          New Feature

          Surface actionable competitive intel

          Learn More
        • Log in
          • Moz Pro
          • Moz Local
          • Moz Local Dashboard
          • Moz API
          • Moz API Dashboard
          • Moz Academy
        • Avatar
          • Moz Home
          • Notifications
          • Account & Billing
          • Manage Users
          • Community Profile
          • My Q&A
          • My Videos
          • Log Out

        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. Home
        2. SEO Tactics
        3. Technical SEO
        4. Converting files from .html to .php or editing .htaccess file

        Moz Q&A is closed.

        After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

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

        Technical SEO
        7
        11
        5053
        Loading More Posts
        • Watching

          Notify me of new replies.
          Show question in unread.

        • Not Watching

          Do not notify me of new replies.
          Show question in unread if category is not ignored.

        • Ignoring

          Do not notify me of new replies.
          Do not show question in unread.

        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as question
        Locked
        This topic has been deleted. Only users with question 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
          • 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
            • 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,

                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
                • 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
                  • 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
                    • 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
                      • 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
                        • 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
                          • 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
                            • 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
                              • 1 / 1
                              • First post
                                Last post

                              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.

                              • See all categories

                              Related Questions

                              • AndyKubrin

                                Robots.txt allows wp-admin/admin-ajax.php

                                Hello, Mozzers!
                                I noticed something peculiar in the robots.txt used by one of my clients: Allow: /wp-admin/admin-ajax.php What would be the purpose of allowing a search engine to crawl this file?
                                Is it OK? Should I do something about it?
                                Everything else on /wp-admin/ is disallowed.
                                Thanks in advance for your help.
                                -AK:

                                Technical SEO | | AndyKubrin
                                2
                              • kirmeliux

                                Removing CSS & JS Files from Index

                                Hi, Google has indexed a few .CSS and .JS files that belong to our WordPress plugins and themes. I had them blocked via robots, but realized this doesn't prevent indexation (and can likely hurt us since Google wants to access these files). I've since removed the robots instructions, submitted a removal request via Search Console, but want to make sure they don't come back. Is there a way to put a noindex tag within .CSS and .JS files? Or should I do something with .htaccess instead?

                                Technical SEO | | kirmeliux
                                1
                              • ulefos

                                Remove html file extension and 301 redirects

                                Hi Recently I ask for some work done on my website from a company,  but I am not sure what they've done is right.
                                What I wanted was html file extensions to be removed like
                                /ash-logs.html to /ash-logs
                                also the index.html to www.timports.co.uk
                                I have done a crawl diagnostics and have duplicate page content and 32 page title duplicates. This is so doing my head in please help This is what is in the .htaccess file <ifmodule pagespeed_module="">ModPagespeed on
                                ModPagespeedEnableFilters extend_cache,combine_css, collapse_whitespace,move_css_to_head, remove_comments</ifmodule> <ifmodule mod_headers.c="">Header set Connection keep-alive</ifmodule> <ifmodule mod_rewrite.c="">Options +FollowSymLinks -MultiViews</ifmodule> DirectoryIndex index.html RewriteEngine On 
                                 # Rewrite valid requests on .html files  RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^ %{REQUEST_URI}.html?rw=1 [L,QSA] 
                                 # Return 404 on direct requests against .html files RewriteCond %{REQUEST_URI} .html$  
                                RewriteCond %{QUERY_STRING} !rw=1 [NC]
                                 RewriteRule ^ - [R=404] AddCharset UTF-8 .html # <filesmatch “.(js|css|html|htm|php|xml|swf|flv|ashx)$”="">#SetOutputFilter DEFLATE #</filesmatch> <ifmodule mod_expires.c="">ExpiresActive On
                                ExpiresByType image/gif "access plus 1 years"
                                ExpiresByType image/jpeg "access plus 1 years"
                                ExpiresByType image/png "access plus 1 years"
                                ExpiresByType image/x-icon "access plus 1 years"
                                ExpiresByType image/jpg "access plus 1 years"
                                ExpiresByType text/css "access 1 years"
                                ExpiresByType text/x-javascript "access 1 years"
                                ExpiresByType application/javascript "access 1 years"
                                ExpiresByType image/x-icon "access 1 years"</ifmodule> <files 403.shtml="">order allow,deny allow from all</files> redirect 301 /PRODUCTS http://www.timports.co.uk/kiln-dried-logs
                                redirect 301 /kindling_firewood.html http://www.timports.co.uk/kindling-firewood.html
                                redirect 301 /about_us.html http://www.timports.co.uk/about-us.html
                                redirect 301 /log_delivery.html http://www.timports.co.uk/log-delivery.html redirect 301 /oak_boards_delivery.html http://www.timports.co.uk/oak-boards-delivery.html
                                redirect 301 /un_edged_oak_boards.html http://www.timports.co.uk/un-edged-oak-boards.html
                                redirect 301 /wholesale_logs.html http://www.timports.co.uk/wholesale-logs.html redirect 301 /privacy_policy.html http://www.timports.co.uk/privacy-policy.html redirect 301 /payment_failed.html http://www.timports.co.uk/payment-failed.html redirect 301 /payment_info.html http://www.timports.co.uk/payment-info.html

                                Technical SEO | | ulefos
                                1
                              • moby123

                                Lost with conical, nofollow noindex. Not sure how to use it on a dyanmic php site with multiple region select options

                                I have a site with multiple regions the main page after a region is selected is login.php but the regions are defined by ?rid=11 , 12, etc. These are being picked up as duplicate content but they are all different regions. As i hired external php coders to develop most of the site I am scared to start meddling with any of the raw code and would like some advise on how to not show these as duplicate content. should i use noindex nofollow or connical? if Connical how do i set it up on the main login.php page? p.s. i am an extreme nube to seo

                                Technical SEO | | moby123
                                0
                              • JaredMumford

                                Removing URL Parentheses in HTACCESS

                                Im reworking a website for a client, and their current URLs have parentheses. I'd like to get rid of these, but individual 301 redirects in htaccess is not practical, since the parentheses are located in many URLs. Does anyone know an HTACCESS rule that will simply remove URL parantheses as a 301 redirect?

                                Technical SEO | | JaredMumford
                                0
                              • Yonnir

                                My .htaccess has changed, what do i do to avoid it again...?

                                Hello Today i notice that our site did not auto changed from without www to with, when i checked the .htaccess file i notice # in-front of each line and i know we did not insert it in there, after i removed it it worked fine. The only changes that we did recently was to a mobile version to the site but the call to autodirect is in a JS and not in the .htaccess, could it be the server..? is there any way that anything else might cause this...? The site is HTML and WP could it be because of that...? Thank's Simo

                                Technical SEO | | Yonnir
                                0
                              • Chammy

                                How much impact does bad html coding really have on SEO?

                                My client has a site that we are trying to optimise. However the code is really pretty bad. There are 205 errors showing when W3C validating. The >title>, , <keywords> tags are appearing twice. There is truly excessive javascript. And everything has been put in tables.</keywords> How much do you think this is really impacting the opportunity to rank? There has been quite a bit of discussion recently along the lines of is on-page SEO impacting anymore. I just want to be sure before I recommend a whole heap of code changes that could cost her a lot - especially if the impact/return could be miniscule. Should it all be cleaned up? Many thanks

                                Technical SEO | | Chammy
                                0
                              • BostonWright

                                Restaurant menu SEO: PDF or HTML?

                                Is it better to use a PDF or hard code restaurant menus (or any document for that matter) in HTML? I want the content to be indexed and thought PDF was the way to go for several reasons, but I wanted to get confirmation on this before I move forward.

                                Technical SEO | | BostonWright
                                0

                              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 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                              • Accessibility
                              • Terms of Use
                              • Privacy

                              Looks like your connection to Moz was lost, please wait while we try to reconnect.