Drupal - Gallery2 - Clean URLs - URL Rewrite - .htacess

g3brown

Joined: 2005-10-03
Posts: 5
Posted: Fri, 2005-10-07 21:22

I setup Drupal and Gallery2. I enabled Clean URLs in Drupal and that works. I intergrated Drupal and Gallery2 with the module and all is still well. I enabled URL ReWrite in Gallery2 and that breaks my intergration, although Gallery2 still works if you go directly to sitename/gallery2. I'm guessing this has to do with my '.htaccess'. I currently have 2 .htaccess files. One is in my base Drupal folder, also the base of my website. The other is in /gallery2.

Drupal - .htaccess - sitename/.htaccess

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<Files ~ "(\.(inc|module|pl|sh|sql|theme|engine|xtmpl)|Entries|Repositories|Root|scripts|updates)$">
  Order deny,allow
  Deny from all
</Files>

# Set some options.
Options -Indexes
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More exist in sites/default/settings.php, but
# the following cannot be changed at runtime. The first IfModule is
# for Apache 1.3, the second for Apache 2.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

  # Rewrite old-style URLs of the form 'node.php?id=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.66 2005/03/20 19:15:00 dries Exp $

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

---

Gallery2 - .htaccess - sitename/gallery2/.htaccess

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

    RewriteBase /gallery2/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR] 
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_FILENAME} !main\.php
    RewriteRule .   -   [L]

    
    RewriteCond %{THE_REQUEST} \ /gallery2/admin/(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !main\.php
    RewriteRule .   /gallery2/main.php?g2_view=core.SiteAdmin   [QSA,L]

    RewriteCond %{THE_REQUEST} \ /gallery2/v/(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !main\.php
    RewriteRule .   /gallery2/main.php?g2_view=core.ShowItem   [QSA,L]

    RewriteCond %{THE_REQUEST} \ /gallery2/d/([0-9]+)-([0-9]+)/([^\/]+)(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !main\.php
    RewriteRule .   /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2   [QSA,L]

    RewriteCond %{THE_REQUEST} \ /gallery2/v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !main\.php
    RewriteRule .   /gallery2/main.php?g2_view=core.ShowItem&g2_path=%1   [QSA,L]

</IfModule>

# END Url Rewrite section
 
kiz_0987

Joined: 2005-02-27
Posts: 189
Posted: Fri, 2005-10-07 22:06

It looks to me that you have not set up the rules for G2 URL Rewrite for Drupal correctly. Your rule seems to still have 'v', instead of being 'gallery'. See INSTALL.txt -- partly repeated here:

Note: To get the rewrite module working, you need to first configure and
use it with the standalone Gallery2 install. Once it's working there disable
all the rules except for the 'Show Item' rule and set its URL pattern to: gallery/%path%

And/or see the How-To at http://codex.gallery2.org/index.php/Gallery2:How_to_Embed_Gallery2_in_Drupal#URL_Rewrite

 
g3brown

Joined: 2005-10-03
Posts: 5
Posted: Sat, 2005-10-08 00:15

Heh, guess it would have help if I had actually read the instructions :P. I looked right over the change you need in the URL Rewrite section. Thanks!