TL:DR – Given an appropriate prompt, ChatGPT can write computer code to solve website problems…and more.
I’ve been doing web stuff since 1995, but sometimes running several sites as subdomains I come unstuck with redirects. Change something on one and it makes the same change inadvertently happen on another. It happened today, I wanted to change the way the RSS feeds work for the Sciencebase site, but the changes I made to the .htaccess file in the domain root kept b0rking another of my sites that’s on the same server as a sub-domain.
The problem was that I was getting scraped at the page level by various bots but individual pages on my site don’t have feeds as comments are disabled. There is one main RSS feed for all updates and separate ones for each category and each tag. I tried to fix it, but it was then redirecting the feed for one of my other sites to the main Sciencebase feed.
So I asked ChatGPT to help. I gave it this prompt to begin with:
You are an expert programmer with Apache knowledge, knowledge of redirects and the file .htaccess. Write a code to redirect all individual RSS feed pages generated by a website’s content management system (CMS) to the primary RSS for the site. I do not want you to redirect the RSS feeds assigned to individual category or tag pages.
It replied as follows:
Below the code snippet it added an explanation for each line, which is useful. That didn’t quite work how I was hoping it would, so I spelled out an example of what I wanted to happen:
The site is https://www.sciencebase.com/science-blog An example URL is https://www.sciencebase.com/science-blog/an-artificial-album-cover.html I want to redirect any URLs of this type https://www.sciencebase.com/science-blog/an-artificial-album-cover.html/feed But not any in a category or tag URL They should go to the primary RSS URL for https://www.sciencebase.com/science-blog/
It then gave me a revised version of the code, which worked fine, although needed an additional tweak to block the interfering with the other website problem. It took about ten minutes all in. I could’ve spent an hour or more on a search engine trying to home in a page discussing the exact same scenario. I think it’s all working cleanly now.