https://www.icyphoenix.com/viewtopic.php?f=26&t=1119
-----------------------------------
User20
Mon 12 Feb, 2007 16:53

FAP SUPPORT - Rewrite Jpg Url-s In Album
-----------------------------------
Hello,

Is here any MOD with what  I can rewrite urls
Something like that.
http://smartor.is-root.com/viewtopic.php?t=17972&start=0&postdays=0&postorder=asc&highlight=

Thanks


-----------------------------------
Artie
Mon 12 Feb, 2007 21:05

Re: Rewrite Jpg Url-s In Album
-----------------------------------
That's basicly the same as this (from mg.com) ... and should work

[quote user="PaulW" post="8721"]Just posted on smartor's site...  just a way of maybe including it as a new BBCode field or something for users to copy & then use in other forums (ones which dont allow .php extensions as image url links) and only allow IMG tags to use .JPG .GIF or whatever...

**PROBLEM ONLY**

I have this configured only for .JPG file uploads, so for things like .GIF and .PNG WONT work at all!  unless there is another workaround for that, I'm sorry!  I suppose you could add more lines to the rewrite code to allow .gif and .png extensions for the same, and then modify a script for the bbcode display to detect filetype & show relevant url??  i dont know

Via the .htaccess file, I am doing testing this now on my webasite, and it seems to work!

If you haven't already created a .htaccess file, do so in the ROOT of your forums...

then add this

[code linenumbers=false]
   RewriteEngine On  
   RewriteBase /  
   RewriteRule ^album_pic_([0-9]*).jpg album_pic.php?pic_id=$1 [L,NC] [/code]



RewriteBase is the location of where the forum is, so if it is /phpbb then it should be /phpbb (i think)

I'm still new to the whole .htaccess idea, but it does work! [/quote]


-----------------------------------
User20
Tue 13 Feb, 2007 18:36

Re: Rewrite Jpg Url-s In Album
-----------------------------------
I copied this to my forums root and it ain't work. 
Could you please explain better?
What changes I need to do to show the pictures in other forums?
Thanks.


-----------------------------------
User20
Tue 13 Feb, 2007 18:37

Re: Rewrite Jpg Url-s In Album
-----------------------------------
And My ISP supports mod-rewrite.


-----------------------------------
Artie
Tue 13 Feb, 2007 21:53

Re: Rewrite Jpg Url-s In Album
-----------------------------------
Works for me as below.......

My phpbb_root is [highlight=#FFFFAA]web_root/forum[/highlight] and I placed the htaccess file  in my [highlight=#FFFFAA]web_root[/highlight]
Accessed the pic by [highlight=#FFFFAA]MyDoman.com/pic_[highlight=#FF0000]ID[/highlight].jpg[/highlight]


[codeblock]RewriteEngine On   
RewriteBase / 
RewriteRule ^pic_([0-9]*).jpg forum/album_pic.php?pic_id=$1 [L,NC][/codeblock]

If your web_root is also your phpbb_root try this.....

[codeblock]RewriteEngine On   
RewriteBase / 
RewriteRule ^pic_([0-9]*).jpg album_pic.php?pic_id=$1 [L,NC][/codeblock]

Note that you must have Hotlink Prevention disabled (ACP) to use this short url in any domain other that yours (or have that domain in the allowed list)


-----------------------------------
nims
Thu 12 Jul, 2007 13:33

Re: Rewrite Jpg Url-s In Album
-----------------------------------
Is it possible to rewrite user album urls ?

Like :
www.domain.com/forum/album.php?user_id=123
To
www.domain.com/forum/ablum/username/

I guess we need to fetch the username from the url in album.php and then get the user_id corresponding to this username and then process further. I am not very good at PHP but still I would try, but in the meantime if there are experts who would like to do it I would really appreciate.


-----------------------------------
nims
Thu 12 Jul, 2007 18:03

Re: Rewrite Jpg Url-s In Album
-----------------------------------
OK I have done it but with some problems.
Its now successfully redirecting
www.domain.com/forum/album.php?username=someuser
to
www.domain.com/album/someuser/
But the problem is that its not picking the correct urls of images and other links since all the paths are relative. I need some help here.

Here is what I did : ********** PLEASE DO NOT TRY THIS YET **********


Open [b].HTACCESS file[/b]
[codeblock]
### Rewrite RULE FOR USER ALBUMS
RewriteRule ^album/([^/]+)/?$ /forum/album.php?username=$1 [QSA,L]
[/codeblock]
OPEN [b]album.php[/b]
FIND
[codeblock]
elseif (isset ($_GET['user_id']))
{
	$album_user_id = intval($_GET['user_id']);
}
[/codeblock]
AFTER ADD
[codeblock]
// Display album by username by Manish
elseif (isset ($_POST['username']))
{
	$album_user_name = $_POST['username'];
	$sql_1 = "SELECT * FROM ". USERS_TABLE . " WHERE username = '" . $album_user_name. "'
		AND user_id <> " . ANONYMOUS;
	if( !($result_1 = $db->sql_query($sql_1)) )
	{
		message_die(GENERAL_ERROR, 'Username '.$album_user_name.' does not exist', '', __LINE__, __FILE__, $sql_1);
}
elseif (isset ($_GET['username']))
{
	$album_user_name = $_GET['username'];
	$sql_1 = "SELECT * FROM ". USERS_TABLE . " WHERE username = '" . $album_user_name. "'
		AND user_id <> " . ANONYMOUS;
	if( !($result_1 = $db->sql_query($sql_1)) )
	{
		message_die(GENERAL_ERROR, 'Username '.$album_user_name.' does not exist', '', __LINE__, __FILE__, $sql_1);
	}
	$result_1 = $db->sql_query($sql_1);
	$fetch_1 = $db->sql_fetchrow($result_1);
	$album_user_id = $fetch_1['user_id']; 
	
}
// display album by username by Manish ends
[/codeblock]
OPEN [b]overall_header.tpl[/b]
Change the relative path of stylesheet to absolute
[codeblock]
<link rel="stylesheet" href="http://www.domain.com/forum/templates/subSilver/{T_HEAD_STYLESHEET}" type="text/css">
[/codeblock]


-----------------------------------
nims
Thu 12 Jul, 2007 19:08

Re: Rewrite Jpg Url-s In Album
-----------------------------------
Ok I added the following and I think I am close

OPEN [b]overall_header.tpl[/b]
FIND

<meta http-equiv="Content-Style-Type" content="text/css">
AFTER ADD
<base href="http://www.domain.com/forum/" />


