Friendly URLs via .htaccess

Miscellaneous code snippets and examples that members have posted

Friendly URLs via .htaccess

Postby Maurd » Wed Aug 23, 2006 3:51 am

I hope this is the right forum to post this.

The Usage section of the SigGen documentation has an .htaccess snippet that allows users to reference a more friendly URL to their signature and avatar images.

Taking this idea a step further, I added a few lines to the .htaccess example to allow people to use a more friendly URL to access or link their profile, as well.

Code: Select all
RewriteEngine on
RewriteRule ^(sig|av)/(.*).png$ ./addons/siggen/$1.php?member=$2
RewriteBase /roster/
RewriteRule ^char/(.*)/$ ./char.php?name=$1&server=ServerName [R]


The "RewriteBase" directory will need to be changed to the location of your Roster installation. In my site's case, it is simply http://sitename.com/roster/, so the RewriteBase is /roster/.

The name of your server/realm will also need to be changed at the end of the final RewriteRule.

Placing that .htaccess file in your base roster directory will allow you to replace these links:

Code: Select all
http://sitename/roster/addons/siggen/sig.php?member=CharacterName&saveonly=0
http://sitename/roster/addons/siggen/av.php?member=CharacterName&saveonly=0
http://sitename/roster/char.php?name=CharacterName&server=ServerName


With these:

Code: Select all
http://sitename/roster/sig/CharacterName.png
http://sitename/roster/av/CharacterName.png
http://sitename/roster/char/CharacterName/


The trailing slash after your CharacterName in the third URL is important.

Nothing earth shattering here, but I thought others may find it useful. Moderators, feel free to delete or move this post as you see fit. Thanks. :)

MOD: Post edited for newer version of SigGen (v0.2.4 and higher)
Last edited by Maurd on Sun Mar 25, 2007 4:21 pm, edited 2 times in total.
Maurd
WR.net Apprentice
WR.net Apprentice
 
Posts: 11
Joined: Tue Jul 18, 2006 6:07 pm

Friendly URLs via .htaccess

Postby zanix » Wed Aug 23, 2006 4:29 am

Very nice
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Friendly URLs via .htaccess

Postby figarotic » Sun Mar 25, 2007 3:45 pm

this worked for me at version 172 but at 173 all pictures are shown as without a character.
User avatar
figarotic
WR.net Apprentice
WR.net Apprentice
 
Posts: 15
Joined: Sun Jul 09, 2006 4:31 am
Location: copenhagen, Denmark

Friendly URLs via .htaccess

Postby zanix » Sun Mar 25, 2007 4:22 pm

MOD: First post edited for newer version of SigGen (v0.2.4 and higher)

SigGen 0.2.4 + uses member= for images now, not name=
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Friendly URLs via .htaccess

Postby figarotic » Sun Mar 25, 2007 4:38 pm

Super :) got it now.
User avatar
figarotic
WR.net Apprentice
WR.net Apprentice
 
Posts: 15
Joined: Sun Jul 09, 2006 4:31 am
Location: copenhagen, Denmark


Return to Code Cache

Who is online

Users browsing this forum: No registered users and 0 guests

cron