Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 10-04-2005, 01:56 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
mod_rewrite

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:
Code:
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/br...rchive/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
__________________
Jay Williams | A Different View

Last edited by jaywilliams; 02-25-2008 at 04:01 PM.
Reply With Quote
  #2  
Old 10-04-2005, 03:56 PM
blinking8s's Avatar
blinking8s+ Offline
über loafer
 
Join Date: Oct 2004
Location: Bowling Green, Ky
Posts: 3,428
Send a message via ICQ to blinking8s Send a message via AIM to blinking8s Send a message via MSN to blinking8s Send a message via Skype™ to blinking8s
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
__________________
i should say more clever stuff
Reply With Quote
  #3  
Old 10-04-2005, 05:20 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
Quote:
Originally Posted by blinking8s
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...
Code:
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:
Code:
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:
HTML Code:
index.php?x=browse
and you were viewing photo #2.. it would make this:
HTML Code:
/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...
HTML Code:
/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.
__________________
Jay Williams | A Different View
Reply With Quote
  #4  
Old 10-04-2005, 05:41 PM
Joe[y]'s Avatar
Joe[y]+ Offline
Team Pixelpost
 
Join Date: Mar 2005
Location: UK
Posts: 3,101
Send a message via MSN to Joe[y]
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!
Reply With Quote
  #5  
Old 10-04-2005, 05:45 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
That's great Joe[y]!

Glad you were able to integrate it so quickly!

It's very nice too... I might add.
__________________
Jay Williams | A Different View
Reply With Quote
  #6  
Old 10-22-2005, 06:39 PM
blinking8s's Avatar
blinking8s+ Offline
über loafer
 
Join Date: Oct 2004
Location: Bowling Green, Ky
Posts: 3,428
Send a message via ICQ to blinking8s Send a message via AIM to blinking8s Send a message via MSN to blinking8s Send a message via Skype™ to blinking8s
i'm going to sticky this thread
__________________
i should say more clever stuff
Reply With Quote
  #7  
Old 10-30-2005, 06:59 PM
empiryk's Avatar
empiryk Offline
forum loafer
 
Join Date: Sep 2005
Location: Poland/Cracow
Posts: 15
Quote:
Originally Posted by jaywilliams
Here is my .htaccess file
Where this .htacces should be placed? in root of pixel?
__________________
[ I apologize for my poor english ]
(head)log http://born66.net
Reply With Quote
  #8  
Old 10-30-2005, 07:07 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
Quote:
Originally Posted by empiryk
Where this .htacces should be placed? in root of pixel?
Yes.

Just place the .htacces file in the root directory.
__________________
Jay Williams | A Different View
Reply With Quote
  #9  
Old 10-30-2005, 07:53 PM
empiryk's Avatar
empiryk Offline
forum loafer
 
Join Date: Sep 2005
Location: Poland/Cracow
Posts: 15
Quote:
Originally Posted by jaywilliams
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
__________________
[ I apologize for my poor english ]
(head)log http://born66.net
Reply With Quote
  #10  
Old 10-30-2005, 08:00 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
Quote:
Originally Posted by empiryk
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.
__________________
Jay Williams | A Different View
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 04:46 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs