ZenPage's URL structure with mod rewrite

I am having some questions in about how ZP structures the URL's
Using the ZenPage plugin I was wondering why the "page" directory is needed?

For example:
`
http://www.zpwebsite.com/page/contact
http://www.zpwebsite.com/page/archive
http://www.zpwebsite.com/page/pages
`
...

What I want is like what ZP does default with the news pages:
`
http://www.zpwebsite.com/news
http://www.zpwebsite.com/news/my-second-page
`
The 'pages' does seem to be re-written correctly:
`http://www.zpwebsite.com/pages/about-this-website`

I think the albums vs 'Gallery' is a bit confusing in ZP
I would like to eliminate any 'Gallery' traces, which I think is not clear to the user and go for 'Albums'
So instead of this:
`
http://www.zpwebsite.com/page/gallery/
http://www.zpwebsite.com/my-topalbum/my-subalbum/photo.jpg.php
`
I would like to rewrite a structure like:
`
http://www.zpwebsite.com/albums/
http://www.zpwebsite.com/albums/my-topalbum/my-subalbum/photo.jpg.php
`
What do I have to change for this in the .htaccess file?

`
# htaccess file version 1.4.1;
# When Zenphoto requires changes to the rewrite rules:
# First make a copy of this file as 'oldhtaccess' in the zp-core folder so setup can test for unmodified files
# Update the above and the define in setup.php



RewriteEngine On
RewriteBase /antonputtemans
RewriteRule ^admin/?$ zp-core/admin.php [R,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^albums/?(.+/?)?$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]

##### put no rules before this line #######

# Rewrite rules for removed sitemap.php #
#########################################
RewriteRule ^sitemap\.php index.php?sitemap [L,R=301]

# Rewrite rules for removed RSS files #
#######################################
RewriteCond %{QUERY_STRING} albumtitle=(.*)&albumname=(.*)&lang=".$lang
RewriteRule ^rss\.php/?$ index.php?rss&albumtitle=%1&albumname=%2&lang=%3 [L,R=301]
RewriteCond %{QUERY_STRING} albumtitle=(.*)&albumname=(.*)&lang=(.*)
RewriteRule ^rss\.php/?$ index.php?rss&albumtitle=%1&albumname=%2&lang=%3 [L,R=301]
RewriteCond %{QUERY_STRING} albumtitle=(.*)&folder=(.*)&lang=(.*)
RewriteRule ^rss\.php/?$ index.php?rss&albumtitle=%1&folder=%2&lang=%3 [L,R=301]
RewriteCond %{QUERY_STRING} folder=(.*)&lang=(.*)&albumsmode
RewriteRule ^rss\.php/?$ index.php?rss&folder%1&lang=%2&albumsmode [L,R=301]
RewriteCond %{QUERY_STRING} withimages&lang=(.*)
RewriteRule ^rss-news\.php/?$ index.php?rss-news&withimages&lang=%1 [L,R=301]
RewriteCond %{QUERY_STRING} id=(.*)&title=(.*)&type=(.*)&lang=(.*)
RewriteRule ^rss-comments\.php/?$ index.php?rss-comments&id=%1&title=%2&type=%3&lang=%4 [L,R=301]
RewriteCond %{QUERY_STRING} type=(.*)&lang=(.*)
RewriteRule ^rss-comments\.php/?$ index.php?rss-comments&type=%1&lang=%2 [L,R=301]
RewriteCond %{QUERY_STRING} lang=(.*)&albumsmode
RewriteRule ^rss\.php/?$ index.php?rss&lang=%1&albumsmode [L,R=301]
RewriteCond %{QUERY_STRING} lang=(.*)&category=(.*)
RewriteRule ^rss-news\.php/?$ index.php?rss-news&lang=%1&category=%2 [L,R=301]
RewriteCond %{QUERY_STRING} lang=(.*)
RewriteRule ^rss\.php/?$ index.php?rss&lang=%1 [L,R=301]
RewriteRule ^rss-news\.php/?$ index.php?rss-news&lang=%1 [L,R=301]

#rewrite rule for tinyURLs #
############################
RewriteRule ^tiny/([0-9]+)/?$ index.php?p=$1&t [L,QSA]

############################
RewriteRule index\.php$ index.php [L,QSA]
RewriteRule ^page/([0-9]+)/?$ index.php?page=$1 [L,QSA]
RewriteRule ^page/([A-Za-z0-9_\-]+)/?$ index.php?p=$1 [L,QSA]
RewriteRule ^page/([A-Za-z0-9_\-]+)/([0-9]+)/?$ index.php?p=$1&page=$2 [L,QSA]
RewriteRule ^(.*)/page/([0-9]+)/?$ index.php?album=$1&page=$2 [L,QSA]
RewriteRule ^(.*)/page/([A-Za-z0-9_\-]+)/?$ index.php?album=$1&p=$2 [L,QSA]

# Rewrite rule addition for search #
####################################
RewriteRule ^page/search/fields([0-9]+)/(.*)/([0-9]+)/?$ index.php?p=search&searchfields=$1&words=$2&page=$3 [L,QSA]
RewriteRule ^page/search/fields([0-9]+)/(.*)/?$ index.php?p=search&searchfields=$1&words=$2 [L,QSA]
RewriteRule ^page/search/archive/(.*)/([0-9]+)/?$ index.php?p=search&date=$1&page=$2 [L,QSA]
RewriteRule ^page/search/archive/(.*)/?$ index.php?p=search&date=$1 [L,QSA]
RewriteRule ^page/search/tags/(.*)/([0-9]+)/?$ index.php?p=search&searchfields=tags&words=$1&page=$2 [L,QSA]
RewriteRule ^page/search/tags/(.*)/?$ index.php?p=search&searchfields=tags&words=$1 [L,QSA]
RewriteRule ^page/search/(.*)/([0-9]+)/?$ index.php?p=search&words=$1&page=$2 [L,QSA]
RewriteRule ^page/search/(.*)/?$ index.php?p=search&words=$1 [L,QSA]

# Rewrite additions for zenpage #
#################################
RewriteRule ^pages/?$ index.php?p=pages [L,QSA]
RewriteRule ^pages/(.*)/?$ index.php?p=pages&title=$1 [L,QSA]
RewriteRule ^news/?$ index.php?p=news [L,QSA]
RewriteRule ^news/([0-9]+)/?$ index.php?p=news&page=$1 [L,QSA]
RewriteRule ^news/category/(.*)/([0-9]+)/?$ index.php?p=news&category=$1&page=$2 [L,QSA]
RewriteRule ^news/category/(.*)/?$ index.php?p=news&category=$1 [L,QSA]
RewriteRule ^news/archive/(.*)/([0-9]+)/?$ index.php?p=news&date=$1&page=$2 [L,QSA]
RewriteRule ^news/archive/(.*)/?$ index.php?p=news&date=$1 [L,QSA]
RewriteRule ^news/(.*)/?$ index.php?p=news&title=$1 [L,QSA]

RewriteRule ^(.*)/image/(thumb|[0-9]{1,4})/([^/\\]+)$ zp-core/i.php?a=$1&i=$3&s=$2 [L,QSA]
RewriteRule ^(.*)/image/([^/\\]+)$ zp-core/i.php?a=$1&i=$2 [L,QSA]
RewriteRule ^(.*)/album/(thumb|[0-9]{1,4})/([^/\\]+)$ zp-core/i.php?a=$1&i=$3&s=$2&album=true [L,QSA]

# Catch-all - everything else gets handled in PHP for compatibility. #
######################################################################
RewriteRule ^(.*)/?$ index.php?album=$1 [L,QSA]


`

Comments

  • Perhaps you should do some reading up on mod_rewrite and regular expressions. The short answer is that we need to be able to tell the difference between images, albums, and other Zenphoto objects. In fact, we are doing pretty much exactly what you asked with the `page` directory. It is to custom scripts as 'news`is to news objects.

    I do not see a case where a zenpage page object has a url with page/pages.
  • BTW, you might want to mention what theme you are using incase it is one of the third party themes. That way the author might notice and comment.

    But on your question of the url `http://www.zpwebsite.com/page/gallery/` This url will specifically load the `gallery.php` script from your theme. I suppose you can just rename that script to `albums.php` if you do not like "gallery"
  • Oh yeah I am already doing :-)
    I tried to pull out al the `page` rewrites but that didn't do it. I guess it's more complicated than that.. Is it possible?

    I only want:
    `
    http://www.zpwebsite.com/news
    http://www.zpwebsite.com/news/my-article
    http://www.zpwebsite.com/archive
    http://www.zpwebsite.com/contact
    http://www.zpwebsite.com/search
    `
    without the `page` part

    I don't understand why the gallery index is
    `http://www.zpwebsite.com/page/gallery`
    when an album is
    `http://www.zpwebsite.com/page/my-album`
    instead I want the gallery index to be:
    `http://www.zpwebsite.com/albums/`
    with albums
    `http://www.zpwebsite.com/albums/my-album`
  • Oh didn't see that reply.
    Rename gallery.php to albums.php. I seeee.
    I'll give it a go :-)

    But is it possible to leave out the `page` part?

    PS I am modding the Zenpage theme
  • mmm renaming gallery.php to albums.php does not do it :-(

    Edit, sorry it does! But again only with the `pages` bit
    `http://www.zpwebsite.com/page/albums`
  • I'll leave this for acrylian to comment on since he is the expert on that theme. It may well have hard code on the gallery.php script.

    In as far as leaving out the `page` part, I think I did explain above that you cannot do that. Of course if you are an expert on .htaccess, you can, but then you will also not be able to have any albums with names like your theme script names.
  • I just did some searches for `/page/` in ZP, jeah it's hardcoded in quite a few functions.
    I could, but don't want to mod the core files. Bummer.

    It's not realy an issue for me the page part. It's just that I am thinking about SEO.
    It will confuse the search engines. Look at the breadcrumbs.

    The gallery index of ZP is
    `http://www.zpwebsite.com/page/gallery`
    and an album
    `http://www.zpwebsite.com/my-album`

    doesn't make sense,... it should be
    http://www.zpwebsite.com/gallery/my-album
    again, just like the news pages, they are perfect.
  • It could possibly have been possible to use "gallery" as a trigger, but Zenphoto was working assuming albums and images long before there were any other alternatives, so that functionality has been left. Since it assumes albums and images, anything else has to have a trigger.

    I seriously doubt that search engines will get confused. Most are not anthromorphic. The url is just a string of characters to them. The breadcrumbs also do not display the link, just the title text, so who is getting confused?

    If you really want `http://www.zpwebsite.com/gallery/my-album
    ` you can make a rewrite rule that eliminates the initial "gallery" from the URL

    But of course, as you say, you really should not care. The URL is not the thing. You could even use the Zenphoto tinyURL function to have really simple urls that end up at the same points.
  • The other thing you can do without doing all that is use the custom menu plugin and have it link to just your albums like I have on mine. You're only getting the page/gallery url when you goto the gallery.php page.

    Goto my site. If you look there, you'll see I created a Gallery label, and then the only thing listed under it are my actual albums, the link for the gallery index isn't on there. That should be the only time you get the page/gallery url. So when you click on my photography album, it goes to inthemdl.net/photography etc, which is what I think you're after as it is.
  • Yeah I see what you are doing, just never show the Gallery index.
    But that's not what I have in mind.
    From a SEO point of view it's just not right.

    My main menu is: Gallery | Pages | News | Contact

    Clicking on any of these will get you to their indexes:
    `http://www.zpwebsite.com/gallery/`
    `http://www.zpwebsite.com/pages/`
    and so on.

    Going deeper in the Gallery needs to give the breadcrumb:
    `Home » Gallery » My Album`
    with the right links, degrading and used consistently.
  • You could still do that by having an album named gallery and just linking to that. I think it's your best bet instead of trying to change the rewrite rules etc which in effect are working exactly as they should. Because what happens is if you try to remove the rule showing page/gallery then any of the other theme pages would fall under default as well. Which then could lead to confusion as to where those files actually are later down the road if you forget the rewrite edits.

    On top of that, when you upgrade to new versions one of the steps may cause the htaccess file to be re-written, then you have to deal with re-writing your edits to it again.

    Also, I don't actually go in and list each of my albums like that, I simply have one entry under the gallery label. A php function entry that consists of the following:
    `
    printAlbumMenuList("list",NULL,"","menu-active","submenu","menu- active","",false,false,false,false,getOption("menu_manager_truncate_string"));
    `
    So when I create new albums etc, it's automatically listed, and there's no gallery index page link.
  • Hi Micheall, using a `Gallery` album as a wrapper, that might work.
    Actually looks a great idea, thanks so much 8)
    I could write a custom functions from the template folder to get my AlbumMenu printed without the wrapper.

    Cheers!
  • acrylian Administrator, Developer
    Yeah, using "gallery" is the best idea. I actually don't think that /pages or not it will affect SEO that much. Many CMS do just use

    Technically I have not implemented a Zenpage pages index page by default but it is not really hard to add that. You just need an extra check on pages.php for that case to show a list or excerpts.

    Btw, you can also "miss-use" albums as normal pages. Just don't put images in an album and use for example the multiple_layouts plugin to mimic them being pages by just using title and description. I did a whole site like that once...;-)
  • Thanks guys, the album wrapper idea has been working great to far.
    Right now I named the album `gallery` but would love to change it to `albums` once I have the `albums` folder in the root renamed with the config file

    Just a big thumbs up for the ZP team that allready provided an option to "omit-top" the wrapper! :-)
    It's the $option parameter in `printAlbumMenuList()`
Sign In or Register to comment.