HighDots Forums  

mod_rewrite faq

Search Engine Optimization Discussion about SEO/Search Engine Optimization (alt.internet.search-engines)


Discuss mod_rewrite faq in the Search Engine Optimization forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tony Hall
 
Posts: n/a

Default mod_rewrite faq - 07-08-2003 , 08:08 AM






Hi

I need to use mod_rewrite to change my links from
http://www.aophotography.com/photo_g...lbum=11&pos=15
to something a little more Google friendly.

Does a step by step guide exist anywhere on how to use mod_rewrite for
a case like this? I found
http://httpd.apache.org/docs/mod/mod_rewrite.html but it does seems to
tell you how the thing works rather than just how to use it.

Regards

Anthony

Reply With Quote
  #2  
Old   
Justin Koivisto
 
Posts: n/a

Default Re: mod_rewrite faq - 07-08-2003 , 09:02 AM






Tony Hall wrote:
Quote:
Hi

I need to use mod_rewrite to change my links from
http://www.aophotography.com/photo_g...lbum=11&pos=15
to something a little more Google friendly.

Does a step by step guide exist anywhere on how to use mod_rewrite for
a case like this? I found
http://httpd.apache.org/docs/mod/mod_rewrite.html but it does seems to
tell you how the thing works rather than just how to use it.
On the bottom of that page there is a link to the Rewriting Guide:
http://httpd.apache.org/docs/misc/rewriteguide.html

You can also find a variety of guides via google:
http://www.google.com/search?q=mod_r...=Google+Search
or
http://www.google.com/search?q=mod_r...=Google+Search

--
Justin Koivisto - spam (AT) koivi (DOT) com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.



Reply With Quote
  #3  
Old   
no one
 
Posts: n/a

Default Re: mod_rewrite faq - 07-08-2003 , 11:36 AM



Tony Hall <olida22 (AT) hotmail (DOT) com> wrote:
Quote:
Hi

I need to use mod_rewrite to change my links from
http://www.aophotography.com/photo_g...lbum=11&pos=15
to something a little more Google friendly.

Does a step by step guide exist anywhere on how to use mod_rewrite for
a case like this?
First figure out what you want the virtual URI (the one people see) to
look like. How about this:

http://www.aophotography.com/photo_g...11_pos_15.html

To map this add two lines to your .htaccess file in photo_gallery/ :

RewriteEngine on
RewriteRule ^album_(.*)_pos_(.*)\.html /photo_gallery/displayimage.php?album=$1&pos=$2 [T=application/x-httpd-php,L]

Presumably you have no other real pages in photo_gallery that start
with "album" - then you should be fine.

--
I.



Reply With Quote
  #4  
Old   
Tony Hall
 
Posts: n/a

Default Re: mod_rewrite faq - 07-08-2003 , 04:15 PM



Thanks for taking the time to reply. I will try that out.

Anthony

Reply With Quote
  #5  
Old   
Tony Hall
 
Posts: n/a

Default Re: mod_rewrite faq - 07-08-2003 , 08:41 PM



Quote:
First figure out what you want the virtual URI (the one people see) to
look like. How about this:

http://www.aophotography.com/photo_g...11_pos_15.html

To map this add two lines to your .htaccess file in photo_gallery/ :

RewriteEngine on
RewriteRule ^album_(.*)_pos_(.*)\.html /photo_gallery/displayimage.php?album=$1&pos=$2 [T=application/x-httpd-php,L]

Presumably you have no other real pages in photo_gallery that start
with "album" - then you should be fine.
Thank you. Your post gave me a good starting point. The only problem
is it does not quite work. I get a "The selected album/picture does
not exist !" which you will see if you follow the link
http://www.aophotography.com/photo_g...11_pos_15.html

After a little reading i realized that the php photo gallery is still
going to show dynamic links from it's pages. I some how need a system
that goes through a page before it is displayed and changes the links
to static ones. It is beginning to sound very complicated! Any help
much appreciated.

Anthony


Reply With Quote
  #6  
Old   
no one
 
Posts: n/a

Default Re: mod_rewrite faq - 07-08-2003 , 08:55 PM



Tony Hall <olida22 (AT) hotmail (DOT) com> wrote:
Quote:
First figure out what you want the virtual URI (the one people see) to
look like. How about this:

http://www.aophotography.com/photo_g...11_pos_15.html

To map this add two lines to your .htaccess file in photo_gallery/ :

RewriteEngine on
RewriteRule ^album_(.*)_pos_(.*)\.html /photo_gallery/displayimage.php?album=$1&pos=$2 [T=application/x-httpd-php,L]
I typed this from my own .htaccess file for something very similar and
mine does work. I did forget one thing (doh regular expressions!) that
might break it. Add a "$" after the ".html" - so it's this:

RewriteRule ^album_(.*)_pos_(.*)\.html$ /photo_gallery/displayimage.php?album=$1&pos=$2 [T=application/x-httpd-php,L]

Quote:
After a little reading i realized that the php photo gallery is still
going to show dynamic links from it's pages. I some how need a system
that goes through a page before it is displayed and changes the links
to static ones. It is beginning to sound very complicated! Any help
much appreciated.
All you really need is a php script to generate every instance of your
photo gallery and then spit out the links HTML-style. A couple of
foreach-loops perhaps? Then put those links into a file Google will
crawl, to point it to each instance of the photo album.

--
I.



Reply With Quote
  #7  
Old   
Justin Koivisto
 
Posts: n/a

Default Re: mod_rewrite faq - 07-09-2003 , 09:22 AM



Tony Hall wrote:
Quote:
After a little reading i realized that the php photo gallery is still
going to show dynamic links from it's pages. I some how need a system
that goes through a page before it is displayed and changes the links
to static ones. It is beginning to sound very complicated! Any help
much appreciated.
One quick solution to this would be to use auto_prepend_file and
auto_append_file along with regex and output buffering.

in .htaccess (put in the photo gallery directory):
--------------------------------------------------
php_value auto_prepend_file /path/to/my/prependfile.php
php_value auto_append_file /path/to/my/appendfile.php

prependfile.php:
----------------
<?php ob_start() ?>

appendfile.php:
---------------
<?php
$contents=ob_get_contents();
ob_end_clean();

// here we have the contents of the output. Now, let's rewrite
// our URLS using regex.
echo preg_replace(
'/displayimage.php\?album=([0-9]*)&pos=([0-9]*)/i',
"album_$1_pos_$2.html",$content
);
?>

This is just off the top of my head, so there may be a couple bugs since
I didn't test it, but it should steer you in the right direction. Hope
it helps!

--
Justin Koivisto - spam (AT) koivi (DOT) com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.



Reply With Quote
  #8  
Old   
Tony Hall
 
Posts: n/a

Default Re: mod_rewrite faq - 07-11-2003 , 03:31 PM



Could some one please tell me why this does not work?

http://www.aophotography.com/photo_g...11_pos_15.html

I followed Mr. no_one's instructions exactly.

Thanks

Anthony

Reply With Quote
  #9  
Old   
no one
 
Posts: n/a

Default Re: mod_rewrite faq - 07-11-2003 , 04:18 PM



Tony Hall <olida22 (AT) hotmail (DOT) com> wrote:
Quote:
Could some one please tell me why this does not work?

http://www.aophotography.com/photo_g...11_pos_15.html

I followed Mr. no_one's instructions exactly.
Please post your .htaccess file so we can review it.

--
I.



Reply With Quote
  #10  
Old   
Tony Hall
 
Posts: n/a

Default Re: mod_rewrite faq - 07-14-2003 , 01:31 PM



Hi

http://www.aophotography.com/photo_gallery/htaccess.txt is a copy of
http://www.aophotography.com/photo_gallery/.htaccess

Thanks

Anthony

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.