Root Site Admin
Joined: 30 Jun 2008 Posts: 14
|
Posted: 03.07.2008, 20:30 Post subject: [Howto] Mode Rewrite = .jpg URLs |
|
|
[Note: This Post is recovered from Smartors old Forum !]
Hi there. This small tutorial will deal with mod_rewrite, short URLs and how to use them
Q&A
Q: Why do I need this? What could I use it for
A: So you can use images as your avatar, within [img] tags in forums etc
Q: What about the other "Album in post" MODs?
A: They are limited to your forum only, if you or your members wish to hotlink on someone else's forum, you'll have to upload it elsewhere, or ask them to install the mod.
Q: What about the other "filename in album" MODs?
A: I'm not sure, but I've only seen one, and it links directly to the image. This is bad for numerous reasons, including that it bypasses the cache, has large filenames and doesn't include your watermark (If you installed it)
Q: What do I need to install this?
A: See below!
Requirements
phpBB latest version
Smartor Album latest version (in the 2.0 line)
Apache with MOD_Rewrite installed (Please note that IIS has a 3rd party plugin, and it might work, but use at your own risk!)
Install
For this, I'll use www.example.org as my site. We'll assume your forum is installed at /, so the pictures are located in example.org/album_mod/upload/
What I have done is I have set up album.example.org, and it redirects requests to /album_mod/uploads/. This step is optional, but nice as it allows direct linking to album.example.org/28.jpg, but you can skip this
Next is you have to decide where the "virtual" directory is to go. If you wish, you could do what I have above, or set it up to be in /albumpics, anything.
Once this is decided, you have to decide where to place the .htaccess file. You have two options. You could place it in the forum root, or you could actually make the directory and stick the .htaccess in there. If you choose the second method, here is the .htaccess file you would use
| Code: | RewriteEngine On
RewriteRule ^(.*).jpg /album_pic.php?pic_id=$1 |
Please note there is some customisation available. The first is what extension you use. Here is .jpg, but you could easily change it to .gif or .png
The next is about using .htaccess in the root folder. If you put it in there, and wish to have the short pictures in /albumpics, here's the .htaccess to use
| Code: | RewriteEngine On
RewriteRule ^albumpics/(.*).jpg /album_pic.php?pic_id=$1 |
And of course albumpics can be changed to whatever you want. So now if you visit example.org/albumpics/28.jpg, it'll redirect to example.org/album_pic.php?pic_id=28. Perfect for telling people, and works in any [img] board tag Smile
Now, you could leave it here, but now here's a simple mod to show this short URL on the picture's album page
open album_page.php
find
| Code: | | 'PIC_TITLE' => $thispic['pic_title'], |
add after
| Code: | | 'PIC_ID' => $thispic['pic_id'], |
find
| Code: | | 'L_PIC_DESC' => $lang['Pic_Desc'], |
add after
| Code: | | 'L_PIC_URL' => $lang['Pic_URL'], |
open language/lang_english/lang_main_album.php
find
| Code: | | $lang['Pic_not_exist'] = |
add after
| Code: | | $lang['Pic_URL'] = 'Pic Address'; |
open templates/subSilver/album_page_body.tpl
find
| Code: | <tr>
<td valign="top" align="right"><span class="genmed">{L_PIC_TITLE}:</span></td>
<td valign="top"><b><span class="genmed">{PIC_TITLE}</span></b></td>
</tr> |
add after
| Code: | <tr>
<td valign="top" align="right"><span class="genmed">{L_PIC_URL}:</span></td>
<td valign="top"><b><span class="genmed">http://album.example.org/{PIC_ID}.jpg</span></b></td>
</tr> |
Important: You will have to customise the last edit to suit your needs!
If you are not using .jpg as your short URL, you must change this
You must change album.example.org/ to your site, and the path you're using. For example, if my actual picture location was www.example.com/images/album/picture.ext, and I was using .png for the short URLs. I'd change the line to http://www.example.com/images/album/{PIC_ID}.png
Save and upload all files
If you're having any trouble, don't hesitate to ask. I hope you found this tutorial useful! Smile
-Edward |
|