How to get WP and WPG2 embedding to work with both mod_rewrites enabled

rubicon

Joined: 2005-09-21
Posts: 5
Posted: Wed, 2005-09-21 08:08

I'm new to G2 and was trying to figure out how to get WPG2 working properly when embedded in WordPress. Here's what I found to work.

First off, both apps use mod_rewrite which causes a problem. At least it does for me if the G2 installation is a subfolder off the root (/gallery) instead of /wordpress/gallery. I'm continuing this message with the assumption of:

G2 installed in /gallery
WP installed in /wordpress

The docs for WPG2 indicate to configure the Embedded Setup URL Rewrites from the wp-gallery2.php page in WP (www.yoursite.com/wordpress/wp-gallery2.php). If you do it through the normal G2 admin page those fields for embedded htaccess don't show up.

The problem is you "can't get there from here" because the mod_rewrites step on each other. What happens is clicking the Site Admin link from the wp-gallery2.php page gives a 404 error. I tricked it out by doing this...

Close all browser windows

Go into G2 Site Admin, turn off the URL Rewrite module but leave it installed

Load the wp-gallery2.php page in WP - click Site Admin - sit tight

There is no link for URL Rewrite in the G2 Site Admin page embedded in WP - that's OK

Toggle back to your normal G2 admin page and re-enable the URL Rewrite module

Toggle back to your wp-gallery2.php page and Refresh the page (don't click any links on the page)

The URL Rewrite link should appear in the left menu, click it, then click Setup

You should see the "hidden" Embedded Setup Htaccess fields appear - enter the proper information as described in the WPG2 docs and click Save

Click the Rules tab and look for the URL Rewrite section and the Show Image field - it will read: v/%path% ; change it to read: %path% ; save the page

You're done

This got everything working just fine. Using the WPG2 tag in my WP posts will correctly display a thumbnail and link to the image.

The developer of WPG2 has suggested turning off G2's mod_rewrite feature if you can't get it to work. That's perfectly fine although you'll get messier URLs when using G2. With G2's mod_rewrite disabled the WPG2 tag still worked using an Album/Photo name such as <wpg2>blogimgs/photo_1.jpg</wpg2>".

This worked for me maybe it will work for you until someone gets the dueling mod_rewrites fixed.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-09-21 12:45

thanks for posting.

but it should work, just not without crafted urls.

www.yoursite.com/wordpress/wp-gallery2.php?g2_view=core.SiteAdmin should bring you to the admin section, from there, you can go to the url rewrite config, enter your stuff, save etc.
doesn't that work?

 
rubicon

Joined: 2005-09-21
Posts: 5
Posted: Wed, 2005-09-21 15:26
valiant wrote:
but it should work, just not without crafted urls.

www.yoursite.com/wordpress/wp-gallery2.php?g2_view=core.SiteAdmin should bring you to the admin section, from there, you can go to the url rewrite config, enter your stuff, save etc. doesn't that work?

I'm sure everyone has a different experience based on their configuration. For me, getting to the main G2 page worked OK via Embedded. Clicking Site Admin relied on the mod_rewrite and the path didn't match up. Since you can't view Embedded Htaccess settings from a normal G2 login, there was no way for me to enter the Embedded Htacces file.

 
swordfish
swordfish's picture

Joined: 2004-10-01
Posts: 388
Posted: Thu, 2005-09-22 03:13

I had a similar experience with mod_rewrite (got to be the most complex Apache module ever designed!) awhile back and it took me days to get it working correctly.
It would work with G2 standalone but not embedded mode no matter what I tried.

I have my WP in a directory off the / root and Gallery in a separate dir off the root.
I have the standalone .htaccess in the gallery dir and via the G2 embedded admin interface created the embedded mode .htaccess which wrote it to my WP root directory. Looked all fine but didn't work. Then I manually created my own .htaccess file but still nothing seemed to work. I'd get it close but then none of my thumbnails would display nor images.

Then, I tried putting the .htaccess file in my Apache root dir (/var/www/localhost/htdocs/) and presto everything worked, short urls and all. Course, my server configuration is probably different from most other folks.

 
GadeTerbob
GadeTerbob's picture

Joined: 2003-11-30
Posts: 13
Posted: Wed, 2005-09-28 23:15

This very thing is about to eat me alive!! The installation has worked (fairly) well since Sept 13, when I installed newest G2. Problem arose while I was trying to get short urls to work. WP is in the domain root, while G2 lives in ../gallery2. Linux server. I can login to admin normally, but clicking the "site admin" link causes this error:

Quote:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator,

and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

This url:

www.yoursite.com/gallery2/wp-gallery2.php?g2_view=core.SiteAdmin

produces this error:

Quote:
Error

An error has occurred.

Back to the Gallery
Error Detail +

I re-ran the installation, reusing old db tables. I've tried deleting the .htaccess file in gallery2, but then everything breaks and I can't even login. I can pm phpinfo or full domain details, if anyone cares to look.

 
rubicon

Joined: 2005-09-21
Posts: 5
Posted: Wed, 2005-09-28 23:34

I got 404 errors when my embedded htaccess files weren't setup properly. You're getting a different error so not sure if my original message would help you.

A 500 error is usually scripting (i.e.: PHP) related.

 
GadeTerbob
GadeTerbob's picture

Joined: 2003-11-30
Posts: 13
Posted: Thu, 2005-09-29 03:23

Well, I tried running the install routine again thinking I could either not install the short url module or not install any modules, but neither of those options were available.

swordfish, I agree. I don't think (now) that mine is the same problem.

 
GadeTerbob
GadeTerbob's picture

Joined: 2003-11-30
Posts: 13
Posted: Thu, 2005-09-29 03:40

http://codex.gallery2.org/index.php/Gallery2:EmbeddedRewrites

Does this mean that there should be a .htaccess file in *each* directory, or just the application directory which in my case is the domain root? When I remove the .htaccess file in the gallery2 directory breaks (at least) thumbnail links.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-29 09:26

yes, in the wp and in the g2 folder should be a .htaccess. the one in the g2 folder isn't really needed if you're accessing your g2 embedded only (and if you don't need the g1 -> g2 redirects).

 
GadeTerbob
GadeTerbob's picture

Joined: 2003-11-30
Posts: 13
Posted: Thu, 2005-09-29 16:48

After I deactivated the G2 plugin in WP, I was finally able to use this url to get into the G2 admin page.

http://www.yourdomain.com/gallery2/main.php?g2_view=core.SiteAdmin

Have removed the url mod in G2 and am starting over.

Thanks All!