URL Rewrite in Drupal Embedded Gallery

kiz_0987

Joined: 2005-02-27
Posts: 189
Posted: Wed, 2005-04-27 23:08

I would like to set up URL Rewrite (0.9.3) in a drupal embedded gallery. I'm using CVS from 2 days ago (beta 2 with cvs mods). Is this possible?

I set up the "Embedded Setup" for URL rewrite with the following:

Htaccess path: - can this be the same as my drupal .htaccess? When I save this and then select and save the rules it seems to change the .htaccess file OK. For now though I'm using an alterate path (drupal/tmp) to avoid any conflict. Any restriction on where this can be?

Public Path - should this be the public path to my embedded drupal? Probably I thought.

I tried a "Test" which runs through fine for the first 2, but then does not provide any reponse (good or bad) to the embedded test.

With the current way it's configured my short urls end up like http://mysite/drupal/v/MyAlbum/
but this does not link to the correct album.

But the drupal embedded mode uses a "gallery" module so that it's url (short for drupal, normal for gallery) is something like:
http://mysite/drupal/gallery?g2_view=core:ShowItem&g2_itemId=2920

mod_rewrite works and I have it running for short drupal urls.

Thanks.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-04-28 00:03

pelle (rewrite) and walkah (drupal) will probably know the answer.

it seems that the short url, http://mysite/drupal/v/MyAlbum/ , should be slightly different. i'd expect something like http://mysite/drupal/gallery/v/MyAlbum/ ...

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Thu, 2005-04-28 11:41

There's a typo in the test, update your cvs and the test result should show up.

@Htaccess Path: It should be the same as your drupal htaccess

 
kiz_0987

Joined: 2005-02-27
Posts: 189
Posted: Fri, 2005-04-29 01:26

Thanks. I updated to fix the typo and the embedded check now works OK. But I still cannot get URL Rewrite to work with Drupal. I can see the thumbnails in the main page but clicking a link gives a file not found error.

I have set the following:
Htaccess path: /var/www/html/drupal
Public path: http://crocus.local/drupal/

I have included the .htaccess file below (which is shared with Drupal's mod_rewrite rules). I also tried a public path of http://crocus.local/drupal/gallery but that gave a "Too many rules" error.

Any ideas would be appreciated.

#
# 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 $
# BEGIN Url Rewrite section
# (Automatically generated.  Do not edit this section)
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /drupal/
    
    # Only redirect to Gallery base file if there's no such file already, and
    # make sure gallery_remote2.php generates a 404 in order to be compatible
    # with Gallery Remote.
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !gallery\_remote2\.php
    RewriteRule ^v/$   /drupal/http://crocus.local/drupal/gallery?g2_view=core:ShowItem   [QSA,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !gallery\_remote2\.php
    RewriteRule ^v/(.+)$   /drupal/http://crocus.local/drupal/gallery?g2_view=core:ShowItem&g2_path=$1   [QSA,L]

</IfModule>

# END Url Rewrite section
 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Fri, 2005-04-29 07:46

Intresting, looks like baseFile is a full URL instead of a file. You see the thumbs because you didnt activate the short style URL for downloads.

valiant, is this normal for embedded mode? I thought baseFile was a file.

You should probably move the Gallery section before Drupal since it has RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-04-29 10:01

pelle, they can set baseFile to be a full url. i don't like that either.
usually, baseFile and embedPath are set with baseFile being something like 'index.php?module=gallery2' and embedPath = '' or '/drupal' . But baseFile = 'http://domain.com/drupal/index.php?module=gallery' is also allowed. for whatever reason.

 
kiz_0987

Joined: 2005-02-27
Posts: 189
Posted: Fri, 2005-04-29 12:19

I tried a couple of ways and either will work.

1) Just modify the .htaccess file to change to

    RewriteRule ^v/(.+)$   /drupal/gallery?g2_view=core:ShowItem&g2_path=$1   [Q
SA,L]

But then the rules would not be rewritten correctly if I changed them.

2) Modified gallery.module in drupal so that $embedUri is relative by setting:
$embedUri = url('gallery', NULL, NULL, FALSE);
The FALSE at the end stops it from being an absolute URL. If this checks out as OK I'll add this as a request to the gallery module.

Using 2) the rules are correctly generated by URL Rewrite but I then manually edit to move them above the Drupal rules as you suggest. Not a big deal.

One usability comment on the URL Rewrite module "Rules" tab. If I add a rule and then come back at a later date and want to add another you have to check both or the original rule is disabled. There is no indication by the checkbox whether it is already there or not.

Thanks for your help.

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Fri, 2005-04-29 15:23
kiz_0987 wrote:
I then manually edit to move them above the Drupal rules as you suggest.

This should only be needed once, as URL Rewrite replaces the current section whenever updated.

kiz_0987 wrote:
There is no indication by the checkbox whether it is already there or not.

When the page is loaded and the checkbox is checked - the rule is active.

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sat, 2005-04-30 16:54

@Absolute URLs in baseFile: I've poked around with this and made the .htaccess file accept these. The rules looks something like this:
RewriteRule ^v/(.+)$ http://example.com/drupal/gallery?g2_view=core:ShowItem&g2_path=$1 [QSA,L]
This works, but I dont like it. Since this'll redirect to non-local adress it wont quetly redirect, instead you'll be seeing http://example.com/drupal/gallery?g2_view=core:ShowItem&g2_path=album/image.jpg.html in the path bar of you browser. This is probably not wat you want - since you get the long format.

The bottom line is; it'll work - but wont be beautiful.