Gallery2:Modules:rewrite - Gallery Codex
Personal tools

Gallery2:Modules:rewrite

From Gallery Codex

URL Rewrite (1.1.x)

Developer Reference

Description

Provides configurable short URLs using mod_rewrite, ISAPI_Rewrite or PathInfo.

Features

  • Shortens URLs to human readable paths.
  • Apache mod_rewrite support.
  • IIS ISAPI_Rewrite support.
  • PHP PathInfo support.
  • Configurable URL patterns.
  • Block hotlinked items (ISAPI_Rewrite and mod_rewrite only)
  • Other modules provide extra functionality
    • Watermark module: Watermark hotlinked items (ISAPI_Rewrite and mod_rewrite only)
    • Permalinks module: Permanent URLs that don't change when you move items.

Usage

Initial configuration page

The configuration page will show you parsing methods available depending on server type (Apache or IIS). If you are unsure of which method to choose you should select either mod_rewrite (Apache) or ISAPI_Rewrite (IIS). The module will test to see if you server supports the parsing method chosen. If all test pass you will be redirected to the Admin Module page and you may now activate the module.

The headings shown on the configuration page are links that activate that specific method. If you want to change the method that you have selected at a later date you will have to uninstall the plugin, install and configure by selecting the method you want to change to.

Requested Features

  • 1224224 Don't append .html to item URLs
  • Change parsing method while the module is active.

Bugs

Currently there are no known issues for this module.

Troubleshooting

How can I check if mod_rewrite is loaded?

Go to the Gallery phpinfo page and look for Loaded Modules. You should see mod_rewrite in the list if it's loaded. Note that the list will be empty if you run PHP in cgi mode.

gallery2/lib/support/index.php?phpinfo

I know mod_rewrite is loaded, why is Gallery telling me it's not working?

If you are the server admin make sure the Gallery directory has the proper AllowOverride rights. Gallery needs to be able to override FileInfo and Options. Put this at the end of your Apache configuration:

<Directory /full/path/to/gallery2>
    AllowOverride FileInfo Options
</Directory>

I lost my .htaccess and now the Site Admin links doesn't work.

See also the Gallery2 FAQ on this topic. Put this in your .htaccess, then go to Site Admin -> URL Rewrite and save the rules to restore your orginal .htaccess.

# BEGIN Url Rewrite section
# (Automatically generated.  Do not edit this section)
<IfModule mod_rewrite.c>
    RewriteEngine On

    # The path to your Gallery (in this case example.com/gallery2/)
    RewriteBase /gallery2/

    RewriteRule ^admin /gallery2/main.php?g2_view=core.SiteAdmin   [QSA,L]
</IfModule>
# END Url Rewrite section

URL Rewrite Embedded

When making any changes to the URL Rewrite configuration (including the rules) you need to access the URL Rewrite admin interface through the embedding application.

Configuring Apache mod_rewrite

Please make sure the Apache user have write access to the .htaccess file in the directory of which the embedding application resides.

touch /var/www/localhost/embedApp/.htaccess
chmod 666 /var/www/localhost/embedApp/.htaccess

If you are not comfortable with leaving everyone with write access to the .htaccess file you may change it back after you have completed the setup and don't plan to change any settings (including the rules under the Setup tab).

chmod 644 /var/www/localhost/embedApp/.htaccess
Access Points

EmbeddedRewrite - Clipboard02.jpg

  1. Navigate to the Site Admin -> Url Rewrite -> Setup tab. Again, you need to be in embedded mode to do this.
  2. Fill out the Htaccess path. This is the physical location of your embedded mode .htaccess file , /var/www/localhost/embedApp).
  3. Fill out the Public path. This is the path to the embedding application that clients will see from the web (eg, /embedApp or /).

Validate

URL Rewrite Tests

EmbeddedRewrite - Clipboard04.jpg

  1. Select the Test tab and look for the Embedded tests
  2. Gallery will test to ensure you have correctly configured the URL Rewrite module.

Configuring IIS ISAPI_Rewrite

EmbeddedRewrite - Clipboard02.jpg

  1. Navigate to the Site Admin -> Url Rewrite -> Setup tab. Again, you need to be in embedded mode to do this.
  2. Fill out the Public path. This is the path to the embedding application that clients will see from the web (eg, /embedApp/ or /).

Configuring PHP Path Info

No need to configure embedded mode. You don't need to be in embedded mode when making any changes to the rules since Gallery will parse the rules.