Skip to Content Skip to Menu

ysva User Profile URL Redirection *Version 2*

  • ysva
  • ysva
  • OFFLINE
  • Posts: 47
  • Thanks: 0
  • Karma: 21
17 years 10 months ago #28301 by ysva
*This is NOT a module*
*This hack is only when Mikko's url plugin or anything else doens't work, it's the final redirection method*
*to make everything work with SEF, read the rest of the topic*


But the most relevant forum to post in...
The old version wasn't very good, but is in the locked forums anyway. (It was actually very bad...)

What does this do?
It makes it possible to have a URL redirection to a user profile without using mod rewrite or SEF (which is unsupported by ISS). It turns things like:

www.joomlapolis.com/timmy_the_slayer

into

www.joomlapolis.com/index.php?option=com_comprofiler&task=userProfile&user='timmy_the_slayer'&Itemid=1


Instructions:
1. Make a 404 errorpage (I assume you know how to do this so I won't explain it) which is a php file (so something like 404.php or 404errorpage.php or givemecookies.php) containing this:

[code:1]
<?php
echo $_SERVER;
?>
[/code:1]

2. Go to your joomlapage and type in anything that you know that doesn't exist, like this:

www.joomlapolis.com/hgjfghsjfldshg


3. You should see your errorpage now, and you should see something like this:

404; www.joomlapolis.com:80/hgjfghsjfldshg


4. Copy that, without the non-existant thing that you typed behind it, which will make you get something like:

404; www.joomlapolis.com:80/


(EVERYTHING has to be included, and so slashes too!)

5. Now replace everything in your errorpage with:

[code:1]<?php

$ysva_thingy="'";
$ysva_publicviewset="&Itemid=1";

if (!strstr($_SERVER,"www."«»))
{

$ysva_replacethis1=str_replace("404; joomlapolis.com:80/ ", "", $_SERVER);

header("Location:http://www.".$_SERVER."/index.php?option=com_comprofiler&task=userProfile&user=".$ysva_thingy.$ysva_replacethis1.$ysva_thingy.$ysva_publicviewset);
}
else
{
$ysva_replacethis2=str_replace("404; www.joomlapolis.com:80/ ", "", $_SERVER);

header("Location:http://".$_SERVER."/index.php?option=com_comprofiler&task=userProfile&user=".$ysva_thingy.$ysva_replacethis2.$ysva_thingy.$ysva_publicviewset);
}
?>[/code:1]

6. As you might have noticed, you need to replace all the

404; www.joomlapolis.com:80/

with wat you got before.

7. Done! There you have your own 404 redirection page to userprofiles of CB. Could you please give me some sweet karma lovin'?

Note:
It might be that you don't use things like
[code:1]index.php?option=com_comprofiler&task=userProfile&user='timmy_the_slayer'[/code:1]
but the searchengine unfriendly one's:
[code:1]/component/option,com_comprofiler/task,userProfile/user,'timmy_the_slayer'/Itemid,1/[/code:1]

Then you need to use this code in your 404 errorpage:

[code:1]<?php

$ysva_thingy="'";
$ysva_publicviewset="/Itemid,1/";

if (!strstr($_SERVER,"www."«»))
{

$ysva_replacethis1=str_replace("404; joomlapolis.com:80/ ", "", $_SERVER);

header("Location:http://www.".$_SERVER."/component/option,com_comprofiler/task,userProfile/user,".$ysva_thingy.$ysva_replacethis1.$ysva_thingy.$ysva_publicviewset);
}
else
{
$ysva_replacethis2=str_replace("404; www.joomlapolis.com:80/ ", "", $_SERVER);

header("Location:http://".$_SERVER."/component/option,com_comprofiler/task,userProfile/user,".$ysva_thingy.$ysva_replacethis2.$ysva_thingy.$ysva_publicviewset);
}
?>[/code:1]

EDIT: To make this automatically get the template and modules you've set for CB, change the 1 in
[code:1]$ysva_publicviewset="/Itemid,1/";[/code:1]
to the Itemid of the menu item for CB!


There you go, that wasn't all to bad for one of my first php creations was it?

Post edited by: ysva, at: 2007/01/04 23:27

Post edited by: ysva, at: 2007/01/04 23:29

Post edited by: ysva, at: 2007/08/30 16:39

Post edited by: ysva, at: 2007/08/30 16:41

Please Log in or Create an account to join the conversation.

  • ysva
  • ysva
  • OFFLINE
  • Posts: 47
  • Thanks: 0
  • Karma: 21
17 years 10 months ago #28302 by ysva
hm...gotta edit the first post...seems you can't use links in boardcode:unsure:

edit: and it's been edited so you can see the links

Post edited by: ysva, at: 2007/01/04 23:28

Please Log in or Create an account to join the conversation.

  • p9939068
  • p9939068
  • OFFLINE
  • Posts: 186
  • Thanks: 0
  • Karma: 117
17 years 10 months ago #28326 by p9939068
Hi
I read through the codes and realized that everything that triggered a 404 will be redirected to profiles, whether or not the profile exist. That's not very elegant i think. Other wise, great work!

Regards, Mike


Mike Feng
Creator of SIMGallery, SIMAnswers, and ParaInvite
www.simbunch.com
twitter.com/simbunch

Please Log in or Create an account to join the conversation.

  • ysva
  • ysva
  • OFFLINE
  • Posts: 47
  • Thanks: 0
  • Karma: 21
17 years 10 months ago #28336 by ysva
thanks!

I don't have the knowledge yet to make it search in the database if the name exists and then go to it, so that will be something for version 3! :woohoo:

Please Log in or Create an account to join the conversation.

17 years 10 months ago #29036 by Codestream
Replied by Codestream on topic Re:ysva User Profile URL Redirection *Version 2*
Hey, this is a great plugin, the one I really need but I'm stuck.. Can't get it to work with my site,,, must be doing something wrong....
The plugin is installed, htaccess file has additional line of code in bottom, at 644. The replacement file does not work with my site, tried it twice... It throws everything into turmoil... The URL's show in the profiles, but won't work.
I get :
"The requested URL //Codestream was not found on this server.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request"

Can anyone provide any help with the redirect? What info do you need??? My site: displaymode.com

Codestream, Los Angeles, CA

Please Log in or Create an account to join the conversation.

  • safa
  • safa
  • OFFLINE
  • Posts: 12
  • Thanks: 0
  • Karma: 1
17 years 8 months ago #32851 by safa
great idea. tested it and it works BEAUTIFULLY.

question for anyone who might know. how could one make this work with openSEF? When the below is added to the code in 404 page associated with openSEF (the one set in the admin component), it doesn't work. The $_SERVER doesn't capture in that case any of the variables associated with URL inputed at first.

Any ideas?

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum