Hello.
I've been trying to do this for a long time but it looks like I don't have enough programming experiance to do this.
I'm trying to make it possible for users to link to their profile using
www.mysite.com/username
instead of mysite.com/component/comprofiler/userprofile/username
I found 2 methods that might be able to do this, but it seems they both need a little tweeking.
#1 the 404 way:
by adding an error.php containing this code to the directory of my template.
Apparently one should change the mandatory menu item name for CB profiles to match the string in the error.php. In this case it's "blogger"
Code:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->code) == '404') {
$profile=str_replace("/", "", $_SERVER['REQUEST_URI']);
header("Location:blogger/userprofile/".$profile.""«»);
exit;
}
?>
However when I try to access a profile like mysite.com/username or any other page that would normaly give me a 404 error, I simply get a blank page instead of being redirected to the profile.
#2 the .htaccess way.
This actually allows users to access their profile by using mysite.com/username.
The problem here is that it makes joomla think that all pages are profiles, therefore giving me the message "This profile does not exist or is no longer available" on almost every page that is not a profile. It also blocks some of my components making that page blank except for the main menu.
Code:
##
# @version $Id: htaccess.txt 1005 2006-10-05 18:00:00Z stingrey $
# @package Joomla
# @copyright Copyright (C) 2006 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##
Options +FollowSymLinks
#
# mod_rewrite in use
#
RewriteEngine On
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update YourJoomlaDirectory (just / for root)
RewriteBase /
#
# Rules
#
#
# ProfileRedirector V 1.3
#
# Make sure your host allows option override
# and has ModRewrite installed
# activate Rewrite enginge
RewriteEngine On
RewriteBase /
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?option=com_comprofiler&task=userProfile&user='$1' [L]
# RewriteRule ^(.*) index.php?cb_username=$1
RewriteCond %{REQUEST_FILENAME} !.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
I find it ard to believe that there is no simpler option in CB to get this done, as this is a very vital function for community based sites. (noone wants to type component/comprofiler/userprofile/ in order to access their profile)
Any help on this would be great.
I see many people have been struggling with this before and I have already wasted way too much time trying to get this done.
Best wishes.