Redirect question

Hello, I will be moving my site over to php from htm.

Has anyone else done this? What htaccess code did you use?


It’s not clear from your question, but assuming all the pages are the same you’ll just need a 301 redirect with a wildcard * rule that automatically forwards anything from html to php.

This should do the trick:

RewriteEngine On
RewriteRule ^(.*).html$ $1.php [L]

Thanks, yes that’s what I’m doing.

Should I have my pages in html or php? It has been suggested to have them in php to allow for greater flexibility.

I always use php nowadays for exactly that reason. In theory there is a tiny performance gain with html, but on static sites like you have with Blocs I can’t see it would ever be an issue unless your server it total junk and you get hit by an avalanche of traffic.

One of my requests for Blocs has been an option to set the default page type in project settings, so it doesn’t have to be set manually on each page.

1 Like

Interesting discussion. @Flashman, I’d be interested in hearing more about changing the file extension to .php from .htm (would that include .html as well?). If a person were to change all .htm files to .php, what are the pros and cons? What other considerations must be made and what potential domino effect(s) may this cause if any? I know little about it, so just wanting to understand a bit better from someone who knows more.

I spent quite a while looking at this a couple years back, but it’s not actually worth getting stressed about.

When a php page is processed by the server it requires a little more processing power, so on a low end server that might be something to consider, but this needs to be kept in perspective. We are talking about a few milliseconds of delay.

Standard Blocs websites are not making use of a database like Wordpress, so they are inherently lighter on resources and the drag from php would only be likely if you had say 100+ people arrive at exactly the same moment on a badly designed website.

I remember once having a low end VPS and seeing a newsletter go out to ten thousand people. I could see from the stats that there were up to 45 people on the site at the same time and when I checked the server resources it peaked at about 3% of available CPU. In words, the server was practically in a coma due to lack of activity…

Certain functions cannot be done with html pages and require php by default, so for that reason I think it makes sense to just choose php from the start and stick with it.

If you happen to be intent on using a really low end hosting package costing $2 a month I would suggest signing up for Cloudflare on a free package. You can then set it to cache everything and the full load is passed to Cloudflare network around the world.

Page loading speed is without doubt important but choosing php over html is very low on that order, whereas the advantages are numerous and that way you won’t have to change at a later stage.

As a quick follow up, Google doesn’t care if a page is php or html, so if you switch page type it’s just important to set up a 301 redirect. At one time there was a small SEO penalty for this, but that is no longer the case. After all, Google wants us all to use https now for good reason and that will actually boost your ranking, but it still requires a 301 redirect.

@Flashman, it sounds like you know a bit about SEO, something I’ve been studying a lot lately as I’m struggling to be seen on the first page of search results. I’m seeing companies that aren’t even web design companies show up higher, even though I have “web design” in my title, meta description, page content etc. I still haven’t discovered the magic keys to getting listed near the top. (I’d settle for the first page). I have even subscribed to several different website SEO audit websites and made changes based on the reports they generate. I’ve increased my score significantly - from on the 50’s to around 90 and yet still struggle to make the first page. I’m stumped. Any suggestions?