Pixelpost Forum

Pixelpost Forum (http://www.pixelpost.org/forum/index.php)
-   Hacks and Modifications (http://www.pixelpost.org/forum/forumdisplay.php?f=16)
-   -   mod_rewrite (http://www.pixelpost.org/forum/showthread.php?t=2317)

jaywilliams 10-04-2005 01:56 PM

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

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

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.

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

Quote:

Originally Posted by jaywilliams
Here is my .htaccess file

Where this .htacces should be placed? in root of pixel?

jaywilliams 10-30-2005 07:07 PM

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.

empiryk 10-30-2005 07:53 PM

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

jaywilliams 10-30-2005 08:00 PM

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.


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

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.