0

this has had me stumped for a few days. Any help would be greatly appreciated.

I think htaccess is probably the best way to do what I need, but if you have a different sdolution I'm glad to hear it.

I am using joomla as my CMS and right now I have a .htacces file right now that will take all urls and send them to the community component of my site.

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

However this will redirect every page Url that doesn't have a directory or file associated with it.

What I need is for the htaccess file to only redirect URLS if they contain the string "community/profile/user"

I still consider myself a noob, and I have spent many days already trying to fix this problem.

Hopefully someone else can shed some light on the issue here. Below is the complete code of my .htaccess file

 ##
# @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

1 Answers1

0

First of all you should remove the double RewriteBase and RewriteEngine.

Now, did you mean something like this:

Options +FollowSymLinks
RewriteBase /

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} \.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ $1 [L]

RewriteRule ^(.*)community/profile/user/(.*)$ index.php?option=com_comprofiler&task=userProfile&user=$2 [L]

The first Rewrite shouldn't change a thing about the path of all the image files. If the URL contains community/profile/user/ then it rewrite the url to index.php?option=com_comprofiler&task=userProfile&user={what-comes-after-user/}

You should be very carefull on what you write with .htaccess because a simple space or a missing capital can end up in a fatal error not loading any pages.

I hope this helps you.

Gijs P
  • 1,325
  • 12
  • 28
  • Thank you very much for trying to help.I tried this, but it gives me a 404 error for ever page other that the default home page. I realize now that I have asked the wrong question. – user695695 Mar 05 '12 at 00:13
  • MY profiles are located under community/profile/user/"username" I need the htaccess file to do nothing unless a URL containing "community/profile/user" is found. if that string is found then it should chanhe the link to mysite.com/"username" but really be showing the page index.php?option=com_comprofiler&task=userProfile&user=$2 Thanks for trying to help! – user695695 Mar 05 '12 at 00:18
  • Ah I see. You are trying to redirect AND rewrite. It's not possible to use the method you want because mysite.com/username will block any other subpages, like mysite.com/contact will redirect to the user "contact". The easier way to do is RewriteRule to "/usr/$2" [R] and then RewriteRule "/usr/(.*)" to index.php?... – Gijs P Mar 05 '12 at 08:59