User Tools

Site Tools


Clean URLs with .htaccess Files

Backlight pages use clean URLs when run in Apache servers in conjunction with the mod_rewrite module and .htaccess files.

In most cases this should work without any need for further configuration. This page serves to document steps needed in the event that clean URLs are not working, or that your site fails completely with the .htaccess files

Clean URLs are not appearing

On launch, Backlight uses clean URLs in two ways:

  1. Page URLs. If you have the Pages module installed, then page URLs should look like one of these, depending on the value of the Page URL Format setting found in the Backlight Settings: /about, /about/, about.html or about.php.
  2. Single image URLs. These links are created in albums, and take the form image1234-single.php.

You'll know that clean URLs are not working, if those URLs are parameter based, such as ?page=about, or single.php?id=image1234. There is no harm in your site creating URLs in this format. Backlight is designed to use this format if .htaccess files are not found, empty or not supported.

If your site is using parameter based URLs there are some steps to take:

  1. For Page URLs, check that the .htaccess file has been copied over from your setup zip file to the top of your site. You may need to configure your FTP client to be able to see hidden files in order to be able to copy this file over.
  2. Check that your server supports .htaccess files and mod_rewrite and over-writing of configuration values in .htaccess files. Such settings are host-specific. You'll need to work with your host's technical support to assist.

You see a message 'No input file specified'

We have made the .htaccess files shipped with Backlight as flexible as possible. However, there are some server setups that we can not cater for out-of-the-box. The 'No input file specified' message is one particular case. This is caused by your host's PHP being configured to run in FastCGI mode.

The main benefit of FastCGI is that it speeds up PHP execution. However, this mode changes the paths on the server, breaking our .htaccess files. Here are some options to resolve this:

  1. Disable FastCGI. This would usually be set via your host's cPanel. As stated above, FastCGI provided performance benefits, so this option is less than ideal.
  2. Edit the .htaccess files to cater to FastCGI setups.

There are two places to edit the contents of the .htaccess files.

  1. For Backlight installations with Pages, you'll need to edit the .htaccess file at the top of your site. The file is annotated with the lines you'll need to change for FastCGI. The edits consist of disabling two lines by adding # to the beginning, and enabling one other line by removing a leading #.
  2. For albums and album sets, the .htaccess file is controlled via a Backlight setting. To update this setting:
  1. Log into Backlight
  2. Click on the Backlight then Settings menu
  3. Scroll to the bottom of the page, and click on Show Advanced Settings
  4. Click on Edit Settings
  5. Edit the contents of the Album .htaccess field
  6. Click Save Settings
  7. Click on the Backlight then Publisher menu
  8. Click on Update Album Files
  9. Click Update

.htaccess files are causing your site to fail completely

Some hosts may disallow .htaccess files or certain directives within the files. Fixing this is beyond the scope of this article. One option is to locate your Apache error file and determine the underlying error. This file may be found via FTP, or via your cPanel.

As stated above, Backlight is designed to work without .htaccess files, albeit without clean URLs in certain locations. As such, removing or renaming the .htaccess file at the top of your site, and following the preceding steps for updating Album .htaccess files so that the field is empty, should solve any issues with .htaccess files.

clean_urls_with_.htaccess_files.txt · Last modified: 2016/05/03 12:30 by ben