mod_rewrite / WPG2 ISSUES?!

cmulder

Joined: 2007-08-12
Posts: 3
Posted: Thu, 2007-10-25 09:36

I've been having problems with configuring the mod_rewrite module to work with my Gallery (2.2.2) which is embedded into Wordpress (2.2) with the help of the WPG2 plugin.

Because of linked logins between Gallery2 and Wordpress, I have to be logged into the Wordpress backend to enter the Gallery2 backend. If I'm not logged into the wordpress backend and I go to the Gallery admin section, it says 'Security Violation... action not permitted'. No problem, just a little background info.

So my gallery installation is located at '/gallery2'

I would like to use the mod_rewrite plugin to have my site's gallery to be at '/images/...' with shortened urls.

After setting the mod_rewrite plugin in the Gallery2 backend, pictures would not load and attempts view albums display 404 errors. I attempted to login to the backend and reconfigure the plugin... but this time, even when logged into the Wordpress backend, I couldn't get in to the 'Site Admin' section no matter how I tried. When I click on 'Site Admin' it redirects me back to my site where I had specified the new 'rewritten' admin url to be in the plugin settings, which is '/images/admin'. This gives a 404 error.

So, I'm locked out of my site admin and thus can't deactivate the mod_rewrite plugin. I tried the following instructions to turn off the plugin:

Quote:
* G2's URL rewrite module is active but doesn't work correctly. Fîx:

1. Put G2 into maintenance mode
2. Browse to http://www.example.com/gallery/main.php?g2_view=core.PluginCallback&g2_pluginId=rewrite&g2_pluginType=module&g2_command=deactivate

So i put it in maintenance mode, tried the link, and it says I'm not logged in and gives an 'Admin Login' link... which of course redirects me back to my site where I had specified the new 'rewritten' admin url to be in the plugin settings, which is '/images/admin'. Again, this gives a 404 error.

So I then tried this section:

Quote:
If the login view doesn't work, you can try to login manually with http://www.example.com/gallery/main.php?g2_controller=core.UserLogin&g2_form[formName]=UserLogin& g2_form[action][login]=Login&g2_form[username]=admin&g2_form[password]=secret (replace "secret" with your own password)

I was able to login, but when I click on 'Site Admin' it once again redirects and gives a 404 error.

I've also tried directly editing my gallery2 directory's .htaccess file, to no avail. I'm an apache newbie. Here's what my butchered htaccess looks like after I tried to edit it... any help?

Quote:
RewriteEngine On

RewriteBase /gallery2/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /images/admin/(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_view=core.SiteAdmin [QSA,L]
RewriteCond %{THE_REQUEST} /images/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /images/([^?]+)/slideshow\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /images/simplefeed/([0-9]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_view=rss.SimpleRender&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /images/feed/([^\/\?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_view=rss.Render&g2_name=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /images/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery2/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} /gallery2/main\.php$
RewriteRule . /gallery2/main.php?g2_view=rewrite.FileNotFound [QSA,L]
</IfModule>

At this point, I'd be happy just with deactivating the plugin and thus getting the login and images working again, and settling for messy links. But it sure would be nice to get the plugin working :D

Thanks in advance!


Gallery version : 2.2.2 Minimal
PHP version : 4.4.7
Webserver : Apache 1.3.37 (Unix)
Database : MYSQL 5.0.27-standard

WORDPRESS GALLERY2 LINK: http://sonechko.burbur.us/images.php

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Thu, 2007-10-25 16:38

Just for the record, we did warn about not using the admin rewrite:

Quote:
Warning: Do not Activate until you have read the following:

Gallery2 simplified URLs may not correctly function in your hosting environment. If you experience any problems (EG: 404 Errors) when navigating to your photos or albums, then please deactivate this setting.

NOTE: You cannot use the Gallery2 "Site Admin" URL rewrite rule with WPG2. It does not work correctly in embedded mode and will break your "Site Admin" link in the embedded gallery. Please ensure that the "Site Admin" rule is off.

Now, let's see about getting you back into your site.

If you use phpmyadmin, you can go to your G2 database, then click on the g2_pluginparametermap table in the left column. Click "Search" at the top of the right window, and then scroll down to the bottom of the search page and enter activeRules in the g_parameterName search box.

Once on the correct record, click the edit button (the pencil to the left of the record). In the resulting window, look at the "Value" pane. You should see something like this:

Quote:
a:5:{s:12:"dynamicalbum";a:3:{i:0;a:1:{s:7:"pattern";s:7:"updates";}i:1;a:1:{s:7:"pattern";s:7:"popular";}i:2;a:1:{s:7:"pattern";s:6:"random";}}s:9:"slideshow";a:1:{i:0;a:1:{s:7:"pattern";s:23:"v/%path%/slideshow.html";}}s:15:"slideshowapplet";a:1:{i:0;a:1:{s:7:"pattern";s:29:"v/%path%/slideshowapplet.html";}}s:6:"webdav";a:2:{s:7:"connect";a:1:{s:7:"pattern";s:7:"w%path%";}s:8:"davmount";a:1:{s:7:"pattern";s:17:"v/%path%.davmount";}}s:7:"rewrite";a:3:{i:0;a:1:{s:7:"pattern";s:8:"v/%path%";}i:1;a:1:{s:7:"pattern";s:36:"d/%itemId%-%serialNumber%/%fileName%";}i:4;a:1:{s:7:"pattern";s:6:"admin/";}}}

Note that the admin rule is at the end of the list from my dev box. Replace all of that with

Quote:
a:0:{}

Now, click "Search" again and enter shortUrls in the g_parameterName search box.

Quote:
a:10:{i:0;a:2:{s:5:"match";a:1:{s:4:"view";s:25:"dynamicalbum.UpdatesAlbum";}s:7:"pattern";s:7:"updates";}i:1;a:2:{s:5:"match";a:1:{s:4:"view";s:25:"dynamicalbum.PopularAlbum";}s:7:"pattern";s:7:"popular";}i:2;a:2:{s:5:"match";a:1:{s:4:"view";s:24:"dynamicalbum.RandomAlbum";}s:7:"pattern";s:6:"random";}i:3;a:4:{s:5:"match";a:1:{s:4:"view";s:19:"slideshow.Slideshow";}s:7:"pattern";s:23:"v/%path%/slideshow.html";s:9:"functions";a:1:{s:4:"path";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:9:"parsePath";}}s:6:"onLoad";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:18:"loadItemIdFromPath";}}i:4;a:4:{s:5:"match";a:1:{s:4:"view";s:31:"slideshowapplet.SlideshowApplet";}s:7:"pattern";s:29:"v/%path%/slideshowapplet.html";s:9:"functions";a:1:{s:4:"path";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:9:"parsePath";}}s:6:"onLoad";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:18:"loadItemIdFromPath";}}i:5;a:3:{s:5:"match";a:1:{s:10:"controller";s:13:"webdav.WebDav";}s:7:"pattern";s:7:"w%path%";s:9:"functions";a:1:{s:4:"path";a:3:{i:0;s:6:"webdav";i:1;s:19:"WebDavRewriteHelper";i:2;s:9:"parsePath";}}}i:6;a:4:{s:5:"match";a:1:{s:4:"view";s:23:"webdav.DownloadDavMount";}s:7:"pattern";s:17:"v/%path%.davmount";s:9:"functions";a:1:{s:4:"path";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:9:"parsePath";}}s:6:"onLoad";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:18:"loadItemIdFromPath";}}i:7;a:4:{s:5:"match";a:1:{s:4:"view";s:13:"core.ShowItem";}s:7:"pattern";s:8:"v/%path%";s:9:"functions";a:3:{s:4:"path";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:9:"parsePath";}s:4:"page";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:9:"parsePage";}s:8:"language";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:13:"parseLanguage";}}s:6:"onLoad";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:18:"loadItemIdFromPath";}}i:8;a:3:{s:5:"match";a:1:{s:4:"view";s:17:"core.DownloadItem";}s:7:"pattern";s:36:"d/%itemId%-%serialNumber%/%fileName%";s:9:"functions";a:2:{s:12:"serialNumber";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:17:"parseSerialNumber";}s:8:"fileName";a:3:{i:0;s:7:"rewrite";i:1;s:19:"RewriteSimpleHelper";i:2;s:13:"parseFileName";}}}i:9;a:2:{s:5:"match";a:1:{s:4:"view";s:14:"core.SiteAdmin";}s:7:"pattern";s:6:"admin/";}}

Again, replace all of that with

Quote:
a:0:{}

Then go to the WPG2 Gallery2 Rewrites tab. Turn off rewrites and then turn them back on. You'll get an error at the top of the screen saying that a variable isn't an array. That's no problem. Your rewrite rules should be reset to the defaults, which do not include the Site Admin rule.

I tested this on my dev box and it worked. Please let me know if it works for you.

Thanks,
Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
cmulder

Joined: 2007-08-12
Posts: 3
Posted: Fri, 2007-10-26 11:48

First, I followed the instructions, but couldn't login to access the plugin area to deactivate the mod_rewrite plugin, just got the same resulting redirect and 404 error :(

So i tried in maintenance mode again and to deactivate the plugin manually:

and it displayed this:

Quote:
{"status":"success","states":{"module":{"rewrite":"inactive"}},"deleted":[]}

So then after a few errors when trying to visit my gallery or login:

Quote:
Error Detail -
Error (ERROR_PERMISSION_DENIED)

* in modules/core/classes/GalleryView.class at line 168 (GalleryCoreApi::error)
* in main.php at line 318 (GalleryView::loadView)
* in main.php at line 94
* in modules/core/classes/GalleryEmbed.class at line 179
* in /home/cmulder/public_html/sonechko/images.php at line 48 (GalleryEmbed::handleRequest)

I started to write this post, then checked the situation again and the rewrite plugin was successfully deactivated! Thus, the admin link redirect isn't working anymore and I was able to login! I went to plugins and re-activated the URL rewrite plugin, and YES, the settings are all back to default.

I wish there was a 'gratitude' smiley!!!

Thank you!!!

Gallery version : 2.2.2 Minimal
PHP version : 4.4.7
Webserver : Apache 1.3.37 (Unix)
Database : MYSQL 5.0.27-standard

WORDPRESS GALLERY2 LINK: http://sonechko.burbur.us/images.php

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-10-26 13:04

Great! Glad it worked in the end.

Just for anyone else reading this thread, you can enable and disable Gallery2 URL rewrites from the WordPress admin panel under WPG2 -> Gallery2 Rewrites. This keeps you out of the loop where you can't get to the G2 Site Admin, because the link is to a broken rewrite rule.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
vcdgeek

Joined: 2005-08-20
Posts: 56
Posted: Mon, 2009-06-08 06:31

Hi, Am having the similar issues
This is the first time i used the wpg2. After enabling the gallery2 rewrite in wordpress setting, my gallery is broken. it doesn't show the photos nor am able to login to admin pages.
but Randomimage link is working fine. [i]I tried running the following url:
http://www.mysite.com.com/g2/main.php?g2_view=core.PluginCallback&g2_pluginId=rewrite&g2_pluginType=module&g2_command=deactivate

it shows messages as {"status":"error"}

Could you pls help me out..