Wordpress PermaLinks VS Gallery2 URL Rewrites

ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2005-06-07 00:36

Right now we cannot get Wordpress and Gallery2 Rewrite features to play well together.. Although I can see what the .htaccess is trying to do I really need a url rewrite expert to help us..

Basically turning on Gallery2 urlrewrites together with Wordpress permalinks = 404 errors..

For example -> http://devtest.ozgreg.com/2005/06/ should be translating to -> http://devtest.ozgreg.com/?m=200506

The rules

# 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} !wp-gallery2.php?
    RewriteRule .   -   [L]

    
      RewriteCond %{QUERY_STRING} view=core.DownloadItem
      RewriteCond %{HTTP_REFERER} !://devtest\.ozgreg\.com/ [NC]
      RewriteRule .   /wp-gallery2.php?   [F,L]

    RewriteCond %{REQUEST_URI} !wp-gallery2.php?
    RewriteRule ^wpg2/$   /wp-gallery2.php?g2_view=core.ShowItem   [QSA,L]

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

    RewriteCond %{REQUEST_URI} !wp-gallery2.php?
    RewriteRule ^view/([0-9]+).html$   /wp-gallery2.php?g2_view=core.ItemAdmin&g2_subView=comment.ShowComments&g2_itemId=$1   [QSA,L]

    RewriteCond %{REQUEST_URI} !wp-gallery2.php?
    RewriteRule ^wpg2/(.+)$   /wp-gallery2.php?g2_view=core.ShowItem&g2_path=$1   [QSA,L]

    RewriteCond %{REQUEST_URI} !wp-gallery2.php?
    RewriteRule ^add/([0-9]+).html$   /wp-gallery2.php?g2_view=core.ItemAdmin&g2_subView=comment.AddComment&g2_itemId=$1   [QSA,L]

    RewriteCond %{REQUEST_URI} !wp-gallery2.php?
    RewriteRule ^(.+)$   /wp-gallery2.php?g2_view=rewrite.FileNotFound&g2_path=$1   [QSA,L]

</IfModule>


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=34]
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
RewriteRule ^page/?([0-9]{1,})/?$ /index.php?&paged=$1 [QSA,L]
RewriteRule ^comments/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1&withcomments=1 [QSA,L]
RewriteRule ^comments/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1&withcomments=1 [QSA,L]
RewriteRule ^comments/page/?([0-9]{1,})/?$ /index.php?&paged=$1 [QSA,L]
RewriteRule ^search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?s=$1&feed=$2 [QSA,L]
RewriteRule ^search/(.+)/(feed|rdf|rss|rss2|atom)/?$ /index.php?s=$1&feed=$2 [QSA,L]
RewriteRule ^search/(.+)/page/?([0-9]{1,})/?$ /index.php?s=$1&paged=$2 [QSA,L]
RewriteRule ^search/(.+)/?$ /index.php?s=$1 [QSA,L]
RewriteRule ^category/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?category_name=$1&feed=$2 [QSA,L]
RewriteRule ^category/(.+)/(feed|rdf|rss|rss2|atom)/?$ /index.php?category_name=$1&feed=$2 [QSA,L]
RewriteRule ^category/(.+)/page/?([0-9]{1,})/?$ /index.php?category_name=$1&paged=$2 [QSA,L]
RewriteRule ^category/(.+)/?$ /index.php?category_name=$1 [QSA,L]
RewriteRule ^author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^author/([^/]+)/page/?([0-9]{1,})/?$ /index.php?author_name=$1&paged=$2 [QSA,L]
RewriteRule ^author/([^/]+)/?$ /index.php?author_name=$1 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&monthnum=$2&day=$3&feed=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&monthnum=$2&day=$3&feed=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /index.php?year=$1&monthnum=$2&day=$3&paged=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index.php?year=$1&monthnum=$2&day=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /index.php?year=$1&monthnum=$2&paged=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/?$ /index.php?year=$1&monthnum=$2 [QSA,L]
RewriteRule ^([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&feed=$2 [QSA,L]
RewriteRule ^([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&feed=$2 [QSA,L]
RewriteRule ^([0-9]{4})/page/?([0-9]{1,})/?$ /index.php?year=$1&paged=$2 [QSA,L]
RewriteRule ^([0-9]{4})/?$ /index.php?year=$1 [QSA,L]
RewriteRule ^([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^([^/]+)/page/?([0-9]{1,})/?$ /index.php?author_name=$1&paged=$2 [QSA,L]
RewriteRule ^([^/]+)/?$ /index.php?author_name=$1 [QSA,L]
</IfModule>
 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Wed, 2005-06-08 14:42

First of all, thats an broken G2 .htaccess. You're missing the '# END Url Rewrite section' comment - next time you update it'll screw it all up.

Secondly, the 404 File Not Found Rule does only work in standalone mode (or to be more specific; only when G2 Rules are the only rules in you .htaccess file).

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Wed, 2005-06-08 23:45

pelle,

the 404 error we are getting is wordpress generated not gallery2... It is the combination of both that is causing the issue..

Nice spot on the #end, no idea why that vanished...

I found a work around on this issue, if the G2 rewrite rules are after Wordpress then it works otherwise the photos return as broken links..