Entries tagged "Web Development"

Check Your Error 404 Database for Broken Links with cURL

Some websites that I maintain have a database for tracking which pages have moved. The problem is that some of the links that indicate where a page has moved to break. So I end up with a 404 error saying a page has moved. When the visitor goes to the new page, they are greeted with another 404 error saying the page has moved. So let's look into writing a script to look through the database for broken links. [Continue reading]

Help Visitors Find Moved Pages with a Simple Error 404 Database

Does your Error 404 page let visitors know where a page has moved to? Or does it have a generic message saying the page has moved and requires the visitor to find the page on their own? With a relatively simple database table and a few lines of code, we can enhance the error page and help customers find what they want faster. [Continue reading]

Disable Directory Indexes and Handle 403 Errors with .htaccess

The websites I develop for normally display the contents of a folder when an index file, like index.php, isn't present. This setup may work for some websites, but not the ones I work on. Instead of adding unnecessary index pages to prevent this type of activity, let's look at how the .htaccess file can help. [Continue reading]

Create Error 404 Page with .htaccess

How does your website handle missing pages? If a page ever gets renamed, moved to a different folder, or removed altogether; what do visitors of the old website address see? If they're greeted with a generic system message, there is a better way. Let's take a quick look at using .htaccess files and creating an Error 404 page to display a more user-friendly message. [Continue reading]

Remove Unnecessary Code by Rethinking Your Default Setting

Over the past few years, I've spent a lot of time revamping my old code. I've been doing what I can to simplify, simply, simplify. While going through the code, I started noticing a pattern when it came to setting defaults. Let's take a look at a quick example and see how I was able to remove the unnecessary code. [Continue reading]

Check for Broken Links with PHP Part 3: Targeted Search

Over the past few weeks we discussed a broken-link checker which leverages PHP's cURL library and DOMDocument. As the code stands, the script checks every link within a given page. That's great if we want to check every link, but what if we want to target a specific section of a page? Let's take a look at how this can be accomplished. [Continue reading]

Check for Broken Links with PHP Part 2: Capture Redirected Links

The link checker discussed previously was designed to report obviously broken links. There is, however, another type of broken link that isn't reported. When a web page is renamed or moved, a redirect may be created so visitors of the old page are automatically sent to the new location. To detect these types of broken links, we'll need to make a few minor modifications. [Continue reading]

Check for Broken Links with PHP Part 1

One aspect of managing a website that I want to streamline is the process of checking for broken links. Clicking on all of those links manually can be tedious. Especially if you have a page dedicated to posting external links. Now I know there are link-checking services available, but I've been looking for an excuse to experiment with cURL which is available through PHP. For those interested, I wanted to share what I have so far. [Continue reading]

Quickly Enter Today’s Date in phpMyAdmin

With the date-field types, phpMyAdmin provides a pop-up calendar for quickly selecting a time frame. However, I commonly create new entries by editing an old row and choosing the "Insert as new row" option. Using older entries causes the calendar to show dates based on the original entry. Since phpMyAdmin doesn't have an option for jumping to today's date, I end up clicking through the calendar options or typing the date manually. Well there's another, sometimes faster, way. [Continue reading]

Pre-Populate Forms that Are Hosted on Other Websites

Lately, I've been more involved with submitting content to other organizations' websites. Getting indexed on those websites helps make the content more widely available. Since the information being submitted is already in a database or doesn't change from submission to submission, it would be nice if I didn't need to re-type or copy/paste everything. Luckily, there is a quicker way. [Continue reading]