Gallery3:User guide:How to shorten the url and remove the /index.php/ - Gallery Codex
Personal tools

Gallery3:User guide:How to shorten the url and remove the /index.php/

From Gallery Codex

How to shorten the url and remove the /index.php/

Find your .htaccess file. It should be located in the root directory of your gallery install. There may be other .htaccess files elsewhere, but this is the one to change.
Open it in an application like "Notepad" or similar text editor.

This is what the file that ships with G3 looks like:

  # <IfModule mod_rewrite.c>
  #  Options +FollowSymLinks
  #  RewriteEngine On
  #  RewriteBase /
  #  RewriteCond %{REQUEST_FILENAME} !-f
  #  RewriteCond %{REQUEST_FILENAME} !-d
  #  RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
  #  RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
  #  RewriteRule ^index.php/(.*) $1 [QSA,R,L]
  # </IfModule>

The #s are the starts of comments. Remove the #s so you can use the lines.

If you have installed gallery in its own directory change the line

  RewriteBase /

to

  RewriteBase /gallery3/

The file should now look like this:

  <IfModule mod_rewrite.c>
   Options +FollowSymLinks
   RewriteEngine On
   RewriteBase /gallery3/
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
   RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
   RewriteRule ^index.php/(.*) $1 [QSA,R,L]
  </IfModule>

If you get a 500 error, then something is wrong. Try changing

  RewriteBase /gallery3/

to

  RewriteBase /gallery3

or try commenting out this line:

  Options +FollowSymLinks

like this

  #Options +FollowSymLinks

The new file looks like this:

  <IfModule mod_rewrite.c>
  # Options +FollowSymLinks
   RewriteEngine On
   RewriteBase /gallery3
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
   RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
   RewriteRule ^index.php/(.*) $1 [QSA,R,L]
  </IfModule>


Appending .html to URL suffix

Edit the /application/config/config.php file and look for the following section:

   /**
    * Fake file extension that will be added to all generated URLs. Example: .html
    */
   $config["url_suffix"] = "/";

In this case, use: $config["url_suffix"] = ".html";

advertisements