PDA

View Full Version : mod_rewrite


jaywilliams
10-04-2005, 01:56 PM
Just want to let you know that I've modified my pixelpost enough using mod_rewrite that you will never see the .php extension or the ?x= in the address box.

Here is my .htaccess file:
Options -Indexes
RewriteEngine on
RewriteRule ^(browse|about)$ index.php?x=$1&pagenum=1
RewriteRule ^browse/([0-9]+)$ index.php?x=browse&category=&pagenum=$1
RewriteRule ^browse/category/([0-9]+)/([0-9]+)$ index.php?x=browse&category=$1&pagenum=$2
RewriteRule ^browse/category/([0-9]+)$ index.php?x=browse&category=$1&pagenum=1
RewriteRule ^comment/([0-9]+)$ index.php?popup=comment&showimage=$1
RewriteRule ^comment/submit$ index.php?x=save_comment
RewriteRule ^photo/([0-9]+)$ index.php?showimage=$1
RewriteRule ^photo/([0-9]+)/rating/([1-5])$ index.php?showimage=$1&rating=$2
RewriteRule ^photo/file/(.+)$ /images/$1
RewriteRule ^thumbnails/latest$ index.php?showthumb=latest&thumbtag=image
RewriteRule ^feeds/(rss|atom).xml$ index.php?x=$1
RewriteRule ^browse/archive/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&pagenum=$2
RewriteRule ^browse/archive/(.*)$ index.php?x=browse&archivedate=$1&pagenum=1

As you can see this will do just about anything.

For example... if I want to see image number 31 I go to:
http://photoblog.differentview.us/photo/31

If I want to post a comment on photo 31 I go to:
http://photoblog.differentview.us/comment/31

The real trick is modifying the browse page to accept options like that.
Browse View Cat 7:
http://photoblog.differentview.us/browse/category/7
Browse View Cat 7 Page 1:
http://photoblog.differentview.us/browse/category/7/1
Browse View Photos during the month of October, 2005:
http://photoblog.differentview.us/browse/archive/2005-10

By using that .htaccess file and by tweaking the links that pixel post uses, you can do the same.

If you would like to get your hands on some already-modified php files, check out my Post Slug addon:
http://www.pixelpost.org/forum/showthread.php?t=4915

blinking8s
10-04-2005, 03:56 PM
thanks for sharing this, i like the way this one handles the structure.

i do have a uestion, not knowing all that much about a link structure rewrite...what happens to all my old url's? will they redirect or still work?

you might want to PM GeoS and talk with him about it, he's handling the rewrite system for future versions of pixelpost

jaywilliams
10-04-2005, 05:20 PM
i do have a uestion, not knowing all that much about a link structure rewrite...what happens to all my old url's? will they redirect or still work?

Good question...

The answer is yes, for the most part...
Let me explain.

Here is a link...
http://www.pixelpost.org/demo/1.4.2/index.php?showimage=2
and if you were using mod_rewrite... this would be the same thing:
http://www.pixelpost.org/demo/1.4.2/photo/2

So in that case both the new and the old links work because both links are absolute.
The only reason they wouldn't is when you start using relative links.

the url /photo/2 is not a real folder.
so if you have an image (or any link) that has a relative url the browser can't process it properly.

Example:
if you had a relive link like this:
index.php?x=browse
and you were viewing photo #2.. it would make this:
/photo/2index.php?x=browse
Which doesn't work... because mod_rewrite doesn't know how to handle that... it is just expecting a number (like 2) not some strange address (like index.php?x=browse).

The trick is to make all urls absolute...

Like this...
/index.php?x=browse
So the browser knows to go to the root directory to load that file.
That goes for images, css and anything that is linked to.

So as long as the link is set to the root directory, like it should be, everything works fine... but as soon as the links start sending to the "virtual" directories it starts messing up.

Remember the slash ( "/" ) and you should be ok.

Joe[y]
10-04-2005, 05:41 PM
i'm using it now! cheers.

didnt' take long to fix my links and tags to suit it:

edit the rewrite a bit to include some other pages:

http://photos.jlspurling.com

cheers!

jaywilliams
10-04-2005, 05:45 PM
That's great Joe[y]!

Glad you were able to integrate it so quickly!

It's very nice too... I might add.

blinking8s
10-22-2005, 06:39 PM
i'm going to sticky this thread

empiryk
10-30-2005, 06:59 PM
Here is my .htaccess fileWhere this .htacces should be placed? in root of pixel?

jaywilliams
10-30-2005, 07:07 PM
Where this .htacces should be placed? in root of pixel?

Yes.

Just place the .htacces file in the root directory.

empiryk
10-30-2005, 07:53 PM
Yes.
Just place the .htacces file in the root directory.Then this seems not work :-(
See: http://klasa.born66.net
.htaccess is placed in root directory of this subdomain

jaywilliams
10-30-2005, 08:00 PM
Then this seems not work :-(
See: http://klasa.born66.net
.htaccess is placed in root directory of this subdomain
It works... you just need to modify the links in pixel post.

eg.
http://klasa.born66.net/photo/14
http://klasa.born66.net/about
http://klasa.born66.net/browse
http://klasa.born66.net/browse/category/1

You get the point.

So look at your templates and the source code for pixel post, and modify the links.

NOTE: Make sure all your links (inc images) are set like this.
/photos/photo.jpg
not like:
photos/photo.jpg

Make sure you have the SLASH at the beginning.

empiryk
10-30-2005, 08:09 PM
So look at your templates and the source code for pixel post, and modify the linksHmm... I am newbe in Pixel then, tell me which parts of templates/source code should be modified? (flies / nr of lines)

GeoS
10-30-2005, 08:31 PM
W /index.php w poszczegolnych linijkach masz:
- ~179 $image_permalink
- ~187 $image_previous_link
- ~204 $image_next_link

Generalnie linki sa w tych okolicach.

empiryk
10-30-2005, 08:37 PM
W /index.php w poszczegolnych linijkach masz:
- ~179 $image_permalink
- ~187 $image_previous_link
- ~204 $image_next_link

Generalnie linki sa w tych okolicach.
Thx, I will take a look into sources tommorow :)
Dziękuję - sprawdzę jutro

Errrwin
11-18-2005, 01:43 PM
I got it to work using another thread I found using good old Google, but I am wondering if it would be possible to use the title of an image instead of the number in the url?

So

http://vollemaan.net/Sachsenhausen

instead of

http://vollemaan.net/14

jaywilliams
11-18-2005, 02:13 PM
I got it to work using another thread I found using good old Google, but I am wondering if it would be possible to use the title of an image instead of the number in the url?

So

http://vollemaan.net/Sachsenhausen

instead of

http://vollemaan.net/14

In theory, yes.
But it would take some modding to the index.php file, and probably the admin.php file as well.

Not an easy task.

You would probably need to make a new row in the database for the url "name" and have the admin.php file put some info in it. And you would need to change the way index.php does links... it works off and ID row, you would need to change it to your url "name" row instead.

EDIT:
This is now possible. I created an addon for Pixelpost that will do this.
Go to http://forum.pixelpost.org/showthread.php?t=4915 for more information.

blinking8s
11-18-2005, 02:23 PM
similar to what jay said, it requires a database input that struos te spaces from the title ect, just like it does with wordpress, and some servers it doesnt work at all with.

GeoS
11-22-2005, 12:28 AM
It doesnt need DB all the time. It only needs to add line for mod_rewrite with this string redirection.

I think that it can be nice addon :)

Sergio de la Torre
11-25-2005, 10:30 AM
I have a beautyful 500 server error :(

GeoS
11-28-2005, 12:07 PM
Do you have mod_rewrite at your hosting place?

jaywilliams
11-28-2005, 02:28 PM
That is a good point...

To do this it requires the Apache web server with the Mod_Rewrite module installed. But the good thing is, this is a fairly common module.

GeoS
11-28-2005, 04:03 PM
Yeap, quite common but it doesnt mean its everytime.

dvolve
12-02-2005, 09:29 AM
Just want to let you know that I've modified my pixelpost enough using mod_rewrite that you will never see the .php extension or the ?x= in the address box.

Here is my .htaccess file:
Options -Indexes
RewriteEngine on
RewriteRule ^(browse|about)$ index.php?x=$1&pagenum=1
RewriteRule ^browse/([0-9]+)$ index.php?x=browse&category=&pagenum=$1
RewriteRule ^browse/category/([0-9]+)/([0-9]+)$ index.php?x=browse&category=$1&pagenum=$2
RewriteRule ^browse/category/([0-9]+)$ index.php?x=browse&category=$1&pagenum=1
RewriteRule ^comment/([0-9]+)$ index.php?popup=comment&showimage=$1
RewriteRule ^comment/submit$ index.php?x=save_comment
RewriteRule ^photo/([0-9]+)$ index.php?showimage=$1
RewriteRule ^photo/([0-9]+)/rating/([1-5])$ index.php?showimage=$1&rating=$2
RewriteRule ^photo/file/(.+)$ /images/$1
RewriteRule ^thumbnails/latest$ index.php?showthumb=latest&thumbtag=image
RewriteRule ^feeds/(rss|atom).xml$ index.php?x=$1
RewriteRule ^browse/archive/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&pagenum=$2
RewriteRule ^browse/archive/(.*)$ index.php?x=browse&archivedate=$1&pagenum=1

As you can see this will do just about anything.

For example... if I want to see image number 31 I go to:
http://photoblog.differentview.us/photo/31

If I want to post a comment on photo 31 I go to:
http://photoblog.differentview.us/comment/31

The real trick is modifying the browse page to accept options like that.
Browse View Cat 7:
http://photoblog.differentview.us/browse/category/7
Browse View Cat 7 Page 1:
http://photoblog.differentview.us/browse/category/7/1
Browse View Photos during the month of October, 2005:
http://photoblog.differentview.us/browse/archive/2005-10

By using that .htaccess file and by tweaking the links that pixel post uses, you can do the same.

Give me a call or drop me an e-mail if you want some of my modified php files or more info on how you can do it.

Phone: 352-397-2506
Skype: d3designs
E-mail: d3designs AT gmail.com
AIM: gwdjay


Hey mate awesome job on the template... could you have one posted for ppl (novices) like me to use and edit aorund... and of course credit will be given in the footers to you.. cheers!

Sergio de la Torre
12-02-2005, 09:48 AM
Yes, i have mod_rewrite. I have deleted "Options -Indexes" And all works fine

"Options -Indexes" is important?

Sergio de la Torre
12-02-2005, 09:50 AM
Another question, ¿How can I redirect old URL to the new system?

Sergio

Joe[y]
12-02-2005, 07:46 PM
Hey mate awesome job on the template... could you have one posted for ppl (novices) like me to use and edit aorund... and of course credit will be given in the footers to you.. cheers!

what's wrong with the one you quoted?

Finner
12-16-2005, 06:53 AM
I too would like a more simple and complete guide on how to implement this for PP novices..
I know a lot has been covered in this thread, but it's over a few posts and gets a little confusing.

I have saved the code and uploaded it to my PP root as a .htaccess file, but am unclear on exactly what to modify and to what...
i.e. how does $image_permalink = "<a href='$showprefix$image_id'>$lang_permalink</a>"; change to /photos/photo.jpg ?

unmake
12-16-2005, 11:05 AM
i.e. how does $image_permalink = "<a href='$showprefix$image_id'>$lang_permalink</a>"; change to /photos/photo.jpg ?

$image_permalink = "<a href="photos/'$image_id'>$lang_permalink</a>";

the cleanest method is to locate the $showprefix definition, and change that to 'photo/' or whatever.

BTW, the new URL's, according to that htaccess anyway, will be "../photo/01" instead of "../index.php?showimage=1" - not "../photo/firstimage_24734763.jpg"

depending on how you've coded your templates, they may need to be modified as well; adding a BASE HREF tag can help resolve relative locatioms..

jaywilliams
12-16-2005, 12:47 PM
"Options -Indexes" is not required to use mod_rewrite.
That simply tells apache not to do directory listings.
Which helps provide a little more security.

As for the template I am currently using...
I built it for my site, so all the modifications I made to it and index.php and the various mods work great on my site.... but if they were used on any other site they won't work. :-(

If I ever make a template again, I will build it so I won't be tethered to my site only.

$image_permalink = "<a href="photos/'$image_id'>$lang_permalink</a>";

the cleanest method is to locate the $showprefix definition, and change that to 'photo/' or whatever.

...
depending on how you've coded your templates, they may need to be modified as well; adding a BASE HREF tag can help resolve relative locations..

unmake is right on.
It's simply a matter of searching your index.php and the various mod php files that you use and setting the path accordingly.

tinyblob
12-16-2005, 01:19 PM
there's no need to modify files, the $showprefix variable is modified if $mod_rewrite is set to 1.

i urge you to avoid modifying pixelpost files since the beta of 1.5 is out soon and you'll just have to make those changes again!

Finner
12-17-2005, 12:02 AM
Thanks for the replies, they were of great help! It all seems to be working well now - http://digerati.farfromreal.com/folio/index.php :D

Ended up just modifying $showprefix and some of the base href's in my template as it didn't seem to want to work w.out the modifications..

DikkieBurger
07-21-2006, 10:40 AM
I added it and it works, but I have 2 problems:
http://www.dikkieburger.nl/photo/14
The thums work and their links too, but the dimensions from the thumbnails don't show up.

http://www.dikkieburger.nl/browse/category/3
This also doen'st work it's looking for thumbnails in
http://www.dikkieburger.nl/browse/category/thumbnails/thumb_20060710231436_dscf2647.jpg
that should be http://www.dikkieburger.nl/thumbnails/thumb_20060710231436_dscf2647.jpg
What should I change in index.php to fix it?

Please help

jaywilliams
07-21-2006, 01:21 PM
For starters, you can try putting the following code inside the <header> section of your template.

<base href="http://www.dikkieburger.nl/">

If that doesn't fix it, you can always open up index.php and modify the image paths so they start with a "/".

CURRENT:
<img src="thumbnails/thumb_20060711222228_dscf2748.jpg" alt="Butterfly" title="Butterfly" class="thumbnails" />
MODIFIED:
<img src="/thumbnails/thumb_20060711222228_dscf2748.jpg" alt="Butterfly" title="Butterfly" class="thumbnails" />

DikkieBurger
07-21-2006, 02:17 PM
Ok, thanks problem solved, but still have the first problem:


http://www.dikkieburger.nl/photo/14
The thumbs work and their links too, but the dimensions of the thumbnails don't show up.

jaywilliams
07-21-2006, 02:26 PM
Wow that's a strange problem there.

What you could do to at least get it working would be to edit the index.php file and make it so it doesn't add the 'width' or the 'height' attributes.

Current:
[<img src='../thumbnails/thumb_20060708114723_oostblok2006_0510(085).jpg' alt='Water organ' title='Water organ' class='thumbnails' width='' height='' />

Modified:
<img src='../thumbnails/thumb_20060708114723_oostblok2006_0510(085).jpg' alt='Water organ' title='Water organ' class='thumbnails' />

DikkieBurger
07-21-2006, 02:51 PM
Mmm, width='$local_width' height='$local_height, the local/width and height are not working

$thumbnail_extra = getimagesize("/thumbnails/thumb_$image_name");
$image_extra = getimagesize("/images/$image_name");
$image_width = $image_extra['0'];
$image_height = $image_extra['1'];
$tpl = str_replace("<IMAGE_WIDTH>",$image_width,$tpl);
$tpl = str_replace("<IMAGE_HEIGHT>",$image_height,$tpl);
$local_width = $thumbnail_extra['0'];
$local_height = $thumbnail_extra['1'];

jaywilliams
07-21-2006, 02:56 PM
Just a hunch, but you might want to remove the "/" at the beginning of getimagesize.

$thumbnail_extra = getimagesize("thumbnails/thumb_$image_name");
$image_extra = getimagesize("images/$image_name");

DikkieBurger
07-21-2006, 03:01 PM
Thanks! Fixed!

jaywilliams
07-21-2006, 03:08 PM
Oh, your RSS feed needs some tweaking.

All your links have two "//". So you always get a 404 error when trying to view the page.

<link>http://www.dikkieburger.nl//photo/17</link>

should be:

<link>http://www.dikkieburger.nl/photo/17</link>

As usual, index.php is the place to look to modify the rss.

DikkieBurger
07-21-2006, 03:16 PM
Thanks, also fixed!

jaywilliams
07-21-2006, 03:22 PM
Well since I'm on such a bug finding spree...
Here is something else for you to fix.

On the Galleries page, you need to change the option for "All".

This is the current code:

<option value='index.php?x=browse&amp;category='>All</option>

It should be:

<option value='/browse'>All</option>

And you know, you can easily change the .htaccess file if you want to rename /browse to /galleries.

Just replace any text that says "browse" with whatever you wish. :-)

DikkieBurger
07-21-2006, 03:39 PM
And thanks again! Think it's fixed know, replaced everything with galleries

sentinel
08-02-2006, 07:12 AM
just a reminder and not specific to pixelpost as such.. mod_rewrite has some "additional features". update recommended read this (http://secunia.com/advisories/21197/)

GeoS
08-02-2006, 07:35 AM
Thanks for the info. Its time to update something :P

jaywilliams
08-21-2006, 06:16 PM
I am wondering if it would be possible to use the title of an image instead of the number in the url?

So

http://vollemaan.net/Sachsenhausen

instead of

http://vollemaan.net/14


YES! That is now possible!
I just released a beta addon called "Post Slug" that does exactly that.
It's for Pixelpost 1.5+ & PHP 5+ so make sure you are running the latest versions of php and pixelpost.

Here is a link to the addon:
http://forum.pixelpost.org/showthread.php?t=4915

Enjoy!

tobbes
08-24-2006, 08:01 PM
What kind of lines do i have to change in template and in source code? Explain step by step, please.



Thanks!

GeoS
08-24-2006, 08:08 PM
It depends from what effect do you want to get (what kind of URLs).

tobbes
08-24-2006, 08:13 PM
Help is not needed anymore, finaly i did it for myself. thanks anyway!

tobbes
08-25-2006, 12:41 PM
Joe[y]:

Slideshow, how? I think i have to add x-tra lines in mod_rewrite, right? But i don't know how the lines look like...

GeoS
08-25-2006, 06:45 PM
Lets say that all base rules for mod_rewrite youve got here:
http://forum.pixelpost.org/showpost.php?p=15673&postcount=1

And here are lines in /index.php to change (in 1.4.2 or 1.5 BETA version so in 1.5 Final it should be near to it):
- ~179 $image_permalink
- ~187 $image_previous_link
- ~204 $image_next_link

Vallhalla
11-16-2006, 03:02 PM
Hi there.. i'm new here and have just finished building a photoblog for a friend using pixelpost. I managed to change most of the links using mod_rewrite, but i'm using the paged archive addon and i don't know how to change the month links using mod rewrite. Eg. a link to the November's image is:

index.php?x=browse&archivedate=2006-11&monthname=November,%202006&pagenum=1

or April's

index.php?x=browse&archivedate=2006-04&monthname=April,%202006&pagenum=1

Now how do i change that to a better looking link with mod_rewrite? Any help is much appreciated. Thanks!

example of the site is at http://taufiqshariff.com/archives/

jaywilliams
11-16-2006, 04:17 PM
Adding the following text to your .htaccess file should do the trick:

RewriteRule ^archives/([0-9-]+)/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&monthname=$2&pagenum=$3



The links would look like this:

/archives/2006-11/November, 2006/1

To modify the links in PixelPost you will need to edit the archives addon.

Vallhalla
11-16-2006, 06:05 PM
Hi.. thanks for your help and the quick reply.. unfortunately its not working for me.. when i use the mod_rewrite you wrote, the new link just took me to the main archive page. eg: http://taufiqshariff.com/archives/2006-11/November,%202006/1 with all the images even if i change the month name, eg:
http://taufiqshariff.com/archives/2006-04/April,%202006/1

Below is how my .htaccess looks like.

RewriteEngine on
RewriteRule ^(links|about)/$ index.php?x=$1
RewriteRule ^archives/ index.php?x=browse&pagenum=1
RewriteRule ^archives/page/([0-9]+)$ index.php?x=browse&category=&pagenum=$1
RewriteRule ^archives/([0-9-]+)/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&monthname=$2&pagenum=$3
RewriteRule ^comment/([0-9]+)$ index.php?popup=comment&showimage=$1
RewriteRule ^photo/([0-9]+)$ index.php?showimage=$1
RewriteRule ^photo/([0-9]+)/rating/([1-5])$ index.php?showimage=$1&rating=$2
RewriteRule ^thumbnails/latest$ index.php?showthumb=latest&thumbtag=image
RewriteRule ^feed/ index.php?x=rss

I don't have any idea why.

jaywilliams
11-16-2006, 06:24 PM
This is just a hunch, but try placing the the the code in a little different order.


Like this:
RewriteRule ^archives/([0-9-]+)/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&monthname=$2&pagenum=$3
RewriteRule ^archives/page/([0-9]+)$ index.php?x=browse&category=&pagenum=$1
RewriteRule ^archives/ index.php?x=browse&pagenum=1

Notice that the "archives/" is listed last.
That might solve it.

Vallhalla
11-16-2006, 06:32 PM
Hey.. that worked... Thank you very much!

SweMike
12-12-2006, 09:28 AM
I have testing all tip here for some day and need some more help.

My site at: http://modul101.com

It´s in swedish and I like swedish words to make sense of the links.

I like a link like this: http://modul101.com/index.php?showimage=65 looks like this: http://modul101.com/bild/65 (this one works when I write the URL in my browser)

And a link like this: http://modul101.com/index.php?x=browse looks like this: http://modul101.com/arkiv (Can write the URL but don´t see any thumbs)

This is the .htaccess, just a test gonna delete som rows later:

<IfModule mod_rewrite.c>
RewriteBase /
Options -Indexes
RewriteEngine on
RewriteRule ^(browse|about|arkiv)$ index.php?x=$1&pagenum=1
RewriteRule ^browse/([0-9]+)$ index.php?x=browse&category=&pagenum=$1
RewriteRule ^browse/category/([0-9]+)/([0-9]+)$ index.php?x=browse&category=$1&pagenum=$2
RewriteRule ^arkiv/category/([0-9]+)$ index.php?x=browse&category=$1&pagenum=1
RewriteRule ^arkiv/([0-9]+)$ index.php?x=browse&category=&pagenum=$1
RewriteRule ^arkiv/category/([0-9]+)/([0-9]+)$ index.php?x=browse&category=$1&pagenum=$2
RewriteRule ^browse/category/([0-9]+)$ index.php?x=browse&category=$1&pagenum=1
RewriteRule ^comment/([0-9]+)$ index.php?popup=comment&showimage=$1
RewriteRule ^comment/submit$ index.php?x=save_comment
RewriteRule ^bild/([0-9]+)$ index.php?showimage=$1
RewriteRule ^bild/([0-9]+)/rating/([1-5])$ index.php?showimage=$1&rating=$2
RewriteRule ^bild/fil/(.+)$ /images/$1
RewriteRule ^thumbnails/latest$ index.php?showthumb=latest&thumbtag=image
RewriteRule ^feeds/(rss|atom).xml$ index.php?x=$1
RewriteRule ^browse/archive/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&pagenum=$2
RewriteRule ^browse/archive/(.*)$ index.php?x=browse&archivedate=$1&pagenum=1
RewriteRule ^arkiv/archive/(.*)/([0-9]+)$ index.php?x=browse&archivedate=$1&pagenum=$2
RewriteRule ^arkiv/archive/(.*)$ index.php?x=browse&archivedate=$1&pagenum=1
RewriteRule ^bild/(.*)$ index.php?photoslug=$1
</IfModule>


Can someone give some help whit the changes in the index-file?
I have done some changes but need more to make everything work ok.

My changes:
Browse should be Arkiv
About should be Info

Excuse me my spelling and bad english...

GeoS
12-12-2006, 09:08 PM
Try to change:
RewriteRule ^(browse|about|arkiv)$ index.php?x=$1&pagenum=1
to:

RewriteRule ^arkiv([/]?)$ index.php?x=browse&pagenum=1
RewriteRule ^info([/]?)$ index.php?x=about

SweMike
12-13-2006, 03:15 AM
EDIT!

Got the links at the main page works, changed both index.php and the template-image.php

If anybody have some info what to change to make the browse page links look the same, please drop a line. (Browse = http://modul101.com/arkiv )
It must be a some change of the code in index.php I belive?
Something with the >THUMBNAILS> tag???

Site: http://modul101.com

Dkozikowski
12-23-2006, 02:01 AM
Ok, I am trying to get
www.sitename.com/index.php?x=browse
and
www.sitename.com/index.php?x=about

to display like

www.sitename.com/browse
and
www.sitename.com/about

I have the following in my .htaccess file,

RewriteEngine On

# Post Slug Addon
RewriteRule ^([a-z0-9-]+)$ index.php?photoslug=$1
RewriteRule ^(browse|about)$ index.php?x=$1&pagenum=1

and changed my browse and about links to /browse and /about in my templates.

When I click either of these links it brings up a blank page with the following words typed on it:
Coming Soon! Nothing to show. No image to show here!

What am I doing wrong here? I am using the POST SLUG addon. Is this messing with it? I don't understand modRewrite at all!

Dkozikowski
12-23-2006, 02:06 AM
This is interesting.

I switched the order of the rewrite rules
to

RewriteEngine On

RewriteRule ^(browse|about)$ index.php?x=$1&pagenum=1
# Post Slug Addon
RewriteRule ^([a-z0-9-]+)$ index.php?photoslug=$1


and now it works!

Why does it make a difference? can someone explain to me why when this:
RewriteRule ^(browse|about)$ index.php?x=$1&pagenum=1
is placed bellow this:
RewriteRule ^([a-z0-9-]+)$ index.php?photoslug=$1

It does not work but if revered it functions as it would.

jaywilliams
12-23-2006, 03:59 AM
can someone explain to me why when this:
RewriteRule ^(browse|about)$ index.php?x=$1&pagenum=1
is placed bellow this:
RewriteRule ^([a-z0-9-]+)$ index.php?photoslug=$1

It does not work but if revered it functions as it would.

Believe it or not, it makes perfect sense. I'll try my best to explain it.

When you uses mod_rewrite it starts with the first rule and progresses to the last one. The rule ([a-z0-9-]+) means any page that uses the letters a through z as well as numbers and hyphens would return true. Both "browse" and "about" fit in that category. So it would get a match and try to load the page "index.php?photoslug=about". And as you can see, that page doesn't exist.

But if the rule (browse|about) is first, and the page you are trying to load is "about", that rule will return true, skipping any further rules. It will then try to load the page "index.php?x=about&pagenum=1", which would be correct.

Hopefully that explains it for you. If not, let me know and I will try again. :-)

Dkozikowski
12-23-2006, 04:06 AM
I understand what you are saying but my thinking was once one line was processed that process ended and went to the next.

So if I understand what you are saying, each process stays active and determins the output of the next?

«XLV»
02-11-2007, 10:18 PM
Could someone help me get URLs like this please?:

http://wvs.topleftpixel.com/07/02/10/

So that date URLs translate nicely into post dates.

A shiny new set of mod_rewrite rules or something would be sweet, or just a few tips. If it's been asked already, a link would be appreciated.

Thanks in advance for any help.

jaywilliams
02-11-2007, 10:55 PM
Could someone help me get URLs like this please?:

http://wvs.topleftpixel.com/07/02/10/

So that date URLs translate nicely into post dates.


Is it possible?
Yes

Is it easy to do?
No

You could setup mod_rewrite like this:
RewriteRule ^([00-99])/([1-12])/([1-31])$ index.php?get_year=$1&get_month=$2&get_day=$3

But unfortunately, the simple mod_rewrite rule would only be a small part.
The larger part would be getting Pixelpost to understand URLs like that.
Which is not an easy task.

«XLV»
02-12-2007, 07:40 PM
Ah, okay. Thanks for trying. Is mod_rewrite used on topleftpixel or is it another photoblog platform entirely do you think?

Something that has passed me by but has now really got me wondering is why PixelPost isn't being developed officially anymore... why is that? :confused:

jaywilliams
02-12-2007, 07:50 PM
Is mod_rewrite used on topleftpixel or is it another photoblog platform entirely do you think?
topleftpixel is definitely using mod_rewrite for those urls.
As for the platform, they are using Movable Type (http://www.movabletype.org/), which isn't a "photoblog" platform out of the box. So they definitely had to do some "hacking" to get everything to work like that. (Which is why I prefer Pixelpost, it works right out of the box)


why PixelPost isn't being developed officially anymore...
Pixelpost is still being actively developed.
Version v1.6 is in the works as we speak. (so I hear)

Dennis
02-13-2007, 12:52 PM
Something that has passed me by but has now really got me wondering is why PixelPost isn't being developed officially anymore... why is that? :confused:

Hmmm... makes me wonder why I did all the code updates and implemented new features for the past 4 months...

Pixelpost is actively developed, and version 1.6 is gonna rock. The major problem here is that we, as a development team, do things in our spare time. And sometimes there are more important things than Pixelpost because we all need to have a roof over our heads and food on the table.

So, please be patient.. we know everyone out there is anxiously for the new release and we release a version soon.

GeoS
02-13-2007, 09:28 PM
Let us know about such ideas.
Definitely Ill try to add it in free time as an addon and thanks to mod_rewrite you will be able to get such a nice links like i.e. yourdomain.com/2007/02/10.

GeoS
02-25-2007, 09:12 PM
For all who want to use dates in navigation you can try this new addon:
http://techblog.piotrgalas.com/?p=9

«XLV»
03-01-2007, 12:02 AM
I sincerely apologise for lack of awareness of your work. I appreciate now that you guys are continuing to put a lot of time and effort into the project and that you have other things to do.

Having only just joined the forum recently all I could see from the homepage were links to an 'old website', forums, etc. and I got the impression that it was a project long since abandoned by its creators and only supported by users.

Now I know the truth, I look forward to 1.6!

Thanks for looking into the date navigation btw GeoS. I'll spend a while tweaking. Though my thumbnail tags hate any mod_rewrite changes... I'll experiment.

Oh, and I think Jay Williams should be upgraded in forum status! He puts a huge amount of support down for n00bs like myself, and has contributed in more than one area of PP development. Great work Jay.

Personne
12-19-2007, 04:32 PM
Great modif !!

Is there an issue to put the name of the pictures / categories like that :

actually

http://www.personnellement.net/index.php?showimage=270

And I'll wish :
http://www.personnellement.net/the next génération


Or for the cat :
http://www.personnellement.net/index.php?x=browse&category=10

And I'll wish :

http://www.personnellement.net/macro/


Thanks

jaywilliams
12-19-2007, 04:35 PM
I actually have a mod_rewrite setup like this for my Pixelpost Photoblog (http://photoblog.dview.us/).
I call the mod "Post Slug", and you can find it for Pixelpost v1.5 (soon to be upgraded to 1.7).

iHamad
12-19-2007, 07:50 PM
definitely waiting for this plugin .. i was going to recommend something like this as an addon .. so i ll just keep an eye for that plugin :D

Personne
12-20-2007, 07:46 AM
Ohhhhhh yes

Exactly what I want !!!

Just 2 questions :

- Does it work for 1.6?
- The .htaccess isn't modify ? can you explain just a little how it works ?


Thanks so much Jaywilliams

jaywilliams
12-20-2007, 04:10 PM
Well basically, the mod adds a new row to the database called "slug".
This slug row contains a "url friendly" version of the title.

For Example:
Image Title: My Sample Image
Image Slug: my-sample-image

Then by patching a few files in Pixelpost, adding some new template tags, and using a little mod_rewrite, one can have urls like this:

example.com/my-sample-image

It can be ported to any version of Pixelpost, but I personally will only have it released for the old v1.5 & the soon to be v1.7.

GeoS
12-20-2007, 09:44 PM
I you can see in last version of Pixelpost (1.7 RC) there is option to use diacretic characters (at least this is the case for polish alphabet). I suggest to add this option also for this post slug solution.
I had small probs with going through mod_rewrite rules with this chars but this issue is solved now :)

Personne
12-24-2007, 09:39 AM
Ok thanks guy !
It's maybe wise to wait the 1.7 version

BandonRandon
01-12-2008, 02:41 AM
Hello,

I posted this thread http://www.pixelpost.org/forum/showthread.php?t=7682 asking a question about re-writing a url it now apperes to me that this is the thread to ask that question.

Here is what i would like to do: re-write the "standard url" index.php?showimage=#&x=something to have all that intact but to add the simple code &PageID=3 this is for a flash menu that uses this code to tell the menu the "current" state. If someone could help me figure out how to do this using the rewrite engine that would be great i think it should only be like 3 lines of code

Brandon

jaywilliams
01-12-2008, 05:16 AM
Well, if you look at the top of this thread, you will see some example mod_rewrite rules.
You can simply add that &PageID=3 to the rule.

rana
04-08-2008, 10:21 AM
Can I use this mod with latest version of pixelpost?

Rana

inocuo
06-05-2008, 10:41 AM
there's no need to modify files, the $showprefix variable is modified if $mod_rewrite is set to 1.

Can you explain how to do that? I tried to do it without modifying fliles but i haven't got it.

Thank you

Kev
01-15-2009, 08:52 AM
i need some help with mod_rewrite please
my test site is www.botesteanu.nu/kev
and i want my urls to look like this

next picture/prev picture: www.botesteanu.nu/kev/name-of-picture
in browse when i select a category www.botesteanu.nu/kev/cat/name-of-category
in browse when i select a month www.botesteanu.nu/kev/month-name
in browse when i select a tag www.botesteanu.nu/kev/tag/name-of-tag

i am using paged_archive plugin.

htaccess looks like thisRewriteEngine on
RewriteBase /kev/
RewriteRule ^(about|downloads)/?$ index.php?x=$1
RewriteRule ^([0-9]+)(.*)$ index.php?showimage=$1
RewriteRule ^browse/?$ index.php?x=browse
RewriteRule ^browse/([1-9][0-9]*)/?$ index.php?x=browse&amp;pagenum=$1
RewriteRule ^browse/category/([1-9][0-9]*)/?$ index.php?x=browse&amp;category=$1
RewriteRule ^browse/category/([1-9][0-9]*)/([1-9][0-9]*)/?$ index.php?x=browse&amp;category=$1&amp;pagenum=$2
RewriteRule ^browse/archive/(19|20)([0-9][0-9])[-](0[1-9]|1[012])/monthname/([^/]+)/?$ index.php?x=browse&amp;archivedate=$1$2-$3&amp;monthname=$4
RewriteRule ^browse/archive/(19|20)([0-9][0-9])[-](0[1-9]|1[012])/monthname/([^/]+)/([1-9][0-9]*)/?$ index.php?x=browse&amp;archivedate=$1$2-$3&amp;monthname=$4&amp;pagenum=$5
RewriteRule ^browse/tag/([^/]+)/?$ index.php?x=browse&amp;tag=$1
RewriteRule ^browse/tag/([^/]+)/([1-9][0-9]*)/?$ index.php?x=browse&amp;tag=$1&amp;pagenum=$2
RewriteRule ^comment/submit$ index.php?x=save_comment
RewriteRule ^comment/([0-9]+)$ index.php?popup=comment&amp;showimage=$1
RewriteRule ^(p|photo)/([0-9]+)$ index.php?showimage=$2
RewriteRule ^(p|photo)/([0-9]+)/rating/([1-5])$ index.php?showimage=$2&amp;rating=$3
RewriteRule ^t/latest/?$ index.php?showthumb=latest&amp;thumbtag=image
RewriteRule ^feeds/(rss|atom).xml$ index.php?x=$1

djib
04-15-2009, 07:23 AM
Has anyone had any luck with geos_date_nav plugin with version 1.7.1 of pixelpost? Do you know if the plugin is still maintained?