More URL Rewrite fun!

notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Sun, 2007-10-07 22:46

I've gotten URL rewrites working in past versions, but I recently upgraded to Wordpress 2.3 and the latest WPG2-3 and everything stopped working.

The site has links like whatever.com/bio, whatever.com/events and they don't work anymore - but my rewrites to whatever.com/gallery1 and whatever.com/gallery2 work fine. No matter what I seem to do, I either lose everything or just the gallery works but not the Wordpress pages.

Here's the latest fun error message - I'll gladly post anything anyone needs who can help me out. This happens when trying to access .com/bio - but the .com/gallery1 work fine. Weird!!

Error (ERROR_MISSING_OBJECT) : Parent 7 path bio

* in modules/core/classes/helpers/GalleryFileSystemEntityHelper_simple.class at line 98 (gallerycoreapi::error)
* in modules/core/classes/GalleryCoreApi.class at line 1853 (galleryfilesystementityhelper_simple::fetchchildidbypathcomponent)
* in modules/core/classes/helpers/GalleryFileSystemEntityHelper_simple.class at line 53 (gallerycoreapi::fetchchildidbypathcomponent)
* in modules/core/classes/GalleryCoreApi.class at line 1804 (galleryfilesystementityhelper_simple::fetchitemidbypath)
* in modules/rewrite/classes/RewriteSimpleHelper.class at line 45 (gallerycoreapi::fetchitemidbypath)
* in ??? at line 0 (rewritesimplehelper::loaditemidfrompath)
* in modules/rewrite/classes/RewriteUrlGenerator.class at line 103
* in modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class at line 37 (modrewriteurlgenerator::_onload)
* in init.inc at line 147 (modrewriteurlgenerator::initnavigation)
* in main.php at line 181
* in main.php at line 95
* in modules/core/classes/GalleryEmbed.class at line 179
* in /home/cust1/user1107304/html/wp-content/plugins/wpg2/wpg2template.inc at line 71 (galleryembed::handlerequest)
* in ??? at line 0
* in /home/cust1/user1107304/html/wp-includes/plugin.php at line 164
* in /home/cust1/user1107304/html/wp-includes/template-loader.php at line 3
* in /home/cust1/user1107304/html/wp-blog-header.php at line 21
* in /home/cust1/user1107304/html/index.php at line 4

System Information
Gallery version 2.2.3
PHP version 4.3.2 cgi
Webserver Apache/2.0.46 (Red Hat) FrontPage/5.0.2.2634 mod_ssl/2.0.46 OpenSSL/0.9.7a
Database mysql 4.1.9-standard-log
Toolkits SquareThumb, NetPBM
Operating system Linux ipswag0005atl2 2.4.21-50.ELsmp #1 SMP Tue May 8 17:18:29 EDT 2007 i686
Browser Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Mon, 2007-10-08 00:07

It would be very helpful to have actual links to the site to see what's happening firsthand.

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Mon, 2007-10-08 11:08

http://danhenk.com/press is a gallery
http://danhenk.com/bio & contact are regular Wordpress pages

This was working fine in previous versions of all apps but as soon as I upgraded to 3.x WPG2, WP2.3 and Gallery2 everything went screwy and i haven't been able to put it back the way it was.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Mon, 2007-10-08 11:43

How do you have it set up that multiple "pages" are galleries? (tattoos, drawings, paintings, and press) That's pretty cool. Haven't seen it before. But since we hadn't tested with anything like that, it may be causing problems with WordPress' internal rewrite engine. Once we understand how you're doing it, I'm sure we can work around it.

Are the normal WordPress pages (bio, contact, ...) showing up in "Manage" -> "Pages"?

It might be very helpful if you could set up a temporary WordPress admin account and PM me the username and password so that I can see what it's doing firsthand. (It would save a lot of back and forth "Is it doing this?" exchanges.)

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Mon, 2007-10-08 12:02

Well, the nav is static so once I had rewrites working previously I just copied the links to each gallery from the main gallery page (it used to be called wp-gallery2.php) - it was just to link directly to the galleries because that's what Dan wanted, he wasn't into having the gallery landing page and then having to click on a gallery to show off his work.

The rewrites were set up in Gallery2 as just %path% or %path%/%page% (I can't remember!!) and I don't remember what my permalink settings were. I do remember it was quite a hassle though!!

I can make the account, but at the moment I have to run out to work. When I get home later tonight (after 7pm EST) I'll PM you some info.

edit - Sorry, forgot to answer one of your questions:
Yes, the other pages are in Manage -> Pages just fine. That's the killer, this was all working before I upgraded. As a last resort, we can be flexible on the URL's but we'd really like to keep things as-is because the site has been up a couple of years and he gets a lot of traffic.

Thanks Kirk!

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Mon, 2007-10-08 12:00

Ahh, so they're actually permalinks for individual albums within one Gallery2 instance, or are they actually seaparate Gallery2 instances?

No problem on tonight. I really can't get to it during the day today anyway.

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Mon, 2007-10-08 12:05
capt_kirk wrote:
Ahh, so they're actually permalinks for individual albums within one Gallery2 instance

Exactly

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Mon, 2007-10-08 12:25

Cool. I had tested permalinks for individual items for the G2 permalinks fix in WPG2 3.0.1, but I hadn't tested album permalinks. It's good to see them working in a visually interesting and fully integrated way.

What I'm not sure of is why that would be breaking other WordPress pages. My bet is that it's a WP permalinks problem.

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

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Tue, 2007-10-09 00:04

So here's the problem: the G2 permalinks URL rewrite rule doesn't have a "code word." It's rewriting EVERY pageslug to the wpg2 page, even the WP pageslugs. The default G2 rewrite rule for permalinks is www.site.com/f/album. You're using www.site.com/album. So, it's trying to rewrite www.site.com/wp_page to a G2 permalink. I can't get to the Gallery2 Site Admin page (or at least I can't figure out how to based on the theme...) So, I can't try changing the G2 Permalinks rewrite rule to test it out. But, I'd try changing the G2 permalinks rewrite rule to something like photos and then changing the link to tattoos to http://danhenk.com/photos/tattoos/ and so forth. bio and the rest of the WP pages should then work.

That's not quite as elegant as just /tattoos/, but I think it's the only way to do it with the internal WP rewrite engine set the way it is.

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Tue, 2007-10-09 01:31

Thanks for trying, when I do that the rest of WP works but the galleries throw an error (similar error to the one posted in my first post).

In the event you want to take a 2nd try, the "site admin" link should appear in the upper right corner just under the logo. I logged in as you and saw it.

If not, let me know so I can remove your account :)

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Tue, 2007-10-09 02:02

I got it working. We were using the same word for two different things. I was talking about the actual G2 Permalinks Plugin, while you were referring to the album's file name. No problem, it became obvious once I could get to the G2 Site Admin.

The problem was that the G2 "Show Item" rewrite rule did not have a "code name." So, I changed it to "photos/%path%" like I explained above.

With it set to just %path$, it was redirecting every WP page to G2. Now it's only directing G2 queries to G2.

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Tue, 2007-10-09 02:14

Thanks Kirk!

That's so weird because with it set to just %path% it had worked previously. Well, all that matters now is that things are working.

Where do we send the bottle of wine?

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Tue, 2007-10-09 02:24

It's because of the way WP handles its internal rewrites. It grabs everything first and tries to process it. Before with wp-gallery2.php, it was only grabbing the pages (bio, etc) and letting all the rest go to wp-gallery2.php and on to G2 because of the .htaccess rules. But now, since we've dumped wp-gallery2.php, we have to duplicate the .htaccess rules in the internal WP rewrite array. You can take a look at this array by using the WP Internal Rewrite Viewer plugin.

Overall, getting rid of wp-gallery2.php is a big plus (mainly for new users and for reducing our support postings saying "have you copied wp-gallery2.php to your WP root, but that's a big plus for us...) But the downside of it is there are a few changes for existing WPG2 sites. Your problem was one I hadn't thought of, but hopefully, this post will help others if they see the same problem.

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Tue, 2007-10-09 02:29

OK, this is weird - the whole thing just stopped working. All I did was go in G2 and shut the keywords off the images. Everything is throwing a 404 now. I didn't touch anything I swear!!

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Tue, 2007-10-09 02:32

Any time you change URL rewrite rules, you need to turn off the URL rewrite rules in the WPG2 G2 Rewrites tab and then turn them back on. That forces WPG2 to update the WP internal rewrite engine.

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

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Tue, 2007-10-09 02:38

Somehow, you had deleted your wpg2 page. It reverted to "WPG2 Output via Standalone Gallery2 Page" under the WPG2 Output tab. I switched it back to "WPG2 Output via Wordpress Page" and it rebuilt your wpg2 page. It looks like it's all working again. (Except for events, but that's a WP permalinks issue that I'll leave for you to figure out. I'm starting to fall asleep and will be dangerous if I mess with it much more...)

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

 
notenslaved

Joined: 2007-10-07
Posts: 8
Posted: Wed, 2007-10-10 04:23

Thanks again Kirk - I'll try not to break it anymore.

Yeah, that event calendar module has been another thorn in my side.

So let me ask this - how do WP permalinks need to be set to not break gallery? Of the 3 options...

Some wine headed your way ;)

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Wed, 2007-10-10 10:49

WP permalinks can be set however you like. All three options work. But if you turn off WP permalinks (by going to "Default"), WPG2 will turn off G2 URL rewrites, which would break your site. Other than that, you can use either of the other two installed options, or use any custom options that you'd like.

The key to your original problem is that G2 URL rewrites cannot have a blank rule. If there was a letter followed by a slash in the default, it must have a letter or word followed by a slash when you modify it.

Thanks for the wine. My wife will be happy that this hobby has finally paid off in a small way!

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

 
nocabt

Joined: 2007-05-25
Posts: 9
Posted: Sun, 2007-11-04 15:27

Hi,

I'm having the exact same problem as notenslaved. Upgraded to wpg2 v3 and suddenly my page slugs all broke! I get a 404 for them or are redirected to wpg2 page, but all embedded G2 pages work perfectly. URL for site is http://thomasbacon.com/. In "show item" in G2 I have "images/%path%"

ideas??

thanks,
thomas

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sun, 2007-11-04 23:20

Follow this thread -> http://gallery.menalto.com/node/71022
____________________________________
Wordpress / Gallery2 (WPG2) Plugin, WPG2 Downloads, WPG2 Documentation

 
jeepinjason

Joined: 2005-10-13
Posts: 5
Posted: Thu, 2007-11-08 18:13

I read that thread but I'm still having similar problems with my WP2.3.1 and WPG2 3.0.2 install. I'm running Gallery 2.2.1 (could that be the issue?).

My WP permalinks use the format: /%category%/%postname%

When I have the URL rewrite plugin in WPG2 turned off everything works fine, but I get the standard cryptic G2 URI structure, which would be fine for the most part (I don't really *need* to have nice clean photo URIs) except it doesn't give me an embeddable image src when I look at the pics (ie: I can't copy the image location into forum posts or anything else and have the image show up).

So with WP permalinks on I get nice URIs for my posts (ie: http://jeepin.net/stuff/hello-world ), but not for WPG2, but everything works.

If I activate the G2 rewrite plugin but don't set the flag in WP, I get nice URIs in G2, but WP comes back saying it can't find any posts if you click one of the links.

If I totally turn on G2 rewrites (activate plugin in G2 and set WPG2 rewrite flag to ON in WP), then G2 works fine and gives me nice URIs (and usable image URIs), but nothing works in Wordpress outside of the main page (looks like it's routing everything to G2). Now http://jeepin.net/stuff/hello-world gives a blank page (FF) or 404 error (IE). I don't have anything outside of G2 that starts with a 'w'.

If I turn off WP permalinks, with the G2 rewrites on, then the WPG2 rewrites work fine (ie: http://jeepin.net/v/trips/ ) but I'm stuck with the default jeepin.net/?p=1 WP link format.

G2 URL rewrite plugin version: 1.1.13 (I have G1-G2 mapping turned on too, if that makes any difference).
G2 rewrite rules:
Show item: v/%path%
Download item: d/%itemId%-%serialNumber%/%fileName%

WP2.3.1 install: http://jeepin.net/
plugin that shows current rewrite rules, WGP2 rewrite turned off: http://jeepin.net/rewrites/ (if I turn on G2 rewrites, I can't access this page anymore).

current root level .htaccess:

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

RewriteBase /

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

RewriteCond %{QUERY_STRING} g2_view=core.DownloadItem
RewriteCond %{QUERY_STRING} g2_itemId=([0-9]+)
RewriteCond %{HTTP:Referer} !^[a-zA-Z0-9\+\.\-]+://jeepin.net/ [NC]
RewriteCond %{HTTP:Referer} !^$
RewriteRule . /photos/main.php?g2_view=watermark.DownloadItem&g2_itemId=%1 [L]
RewriteCond %{THE_REQUEST} /d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/wpg2$
RewriteRule . /photos/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3&g2_GALLERYSID=e0c153c567228ee899e3be2b857d170c [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/wpg2$
RewriteRule . /wpg2?g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/wpg2$
RewriteRule . /wpg2?g2_controller=migrate.Redirect&g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

DirectoryIndex index.php

RedirectMatch permanent (.*)\.asp$ http://jeepin.net$1.php

AddType application/rss+xml rss

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Thu, 2007-11-08 19:18

Your .htaccess shows the embedded page as /wpg2, but from you site it looks like it's really /fotos.

Try switching to standalone mode in the WPG2 Output tab. Then goto Manage -> Pages, and delete any wpg2 or fotos pages that are stuck there (shouldn't be any, but just to be sure). Then put it back to the embedded page in the WPG2 Output tab. Go back to Manage -> Pages and see which page was created. If wpg2 was created, change the pageslug to fotos, if that's what you want. Then try activating the rewrite rules from WPG2 -> Gallery2 Rewrites.

Please let us know if that changes anything.

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

 
jeepinjason

Joined: 2005-10-13
Posts: 5
Posted: Fri, 2007-11-09 20:38

the wpg2 vs fotos thing was changed after I posted (had just discovered how to change the WPG2 output slug).

I did what you said, in the order you said to do it, and all of a sudden now it's working! yahoo! There were no stuck pages in WP after I set WPG2 to standalone, so that was fine. Only thing I did somewhat different was toggle the G1->G2 mapping in the G2 rewrite options, but even with the G1 mapping turned back on it still seems to be working just fine.

Whatever did it, I'm definitely a happy camper now. :)

Thanks!

edit: oh yeah... and I made sure the G2 rewrite rule for show item was 'fotos/%path%', not 'v/%path%' like it was previously...

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-09 20:46
jeepinjason wrote:
edit: oh yeah... and I made sure the G2 rewrite rule for show item was 'fotos/%path%', not 'v/%path%' like it was previously...

Glad it's working!

I think you'll want to change that back to 'v/%path%' or something other than fotos/. Since fotos is your embedded pageslug, WP sees fotos/ as the page, and it may cause problems.

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

 
jeepinjason

Joined: 2005-10-13
Posts: 5
Posted: Fri, 2007-11-09 23:33

if/when I do that and click an album link in G2, WP comes back saying no posts found. It only seems to work if the G2 rewrite uses the same slug ('fotos' in this case) as the WPG2 page.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Fri, 2007-11-09 23:58

No that is not correct, what you are missing, is, if you change the G2 rewrite you MUST revisit the WPG2 Gallery2 rewrite tab in order to add the (changed) Gallery2 rewrite rules to the internal Wordpress Rewrite Array, without this, the rewrites will not correctly function..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo