short url with profile name with .htaccess

I read a few posts explaining how to make user addresses shorter by removing profile out:

www.yourdomain.blah/profile/username

There are several posts discussing this:

http://community.elgg.org/discussion/view/50241/user-profile-url

suggesting the following (one of them...) in the .htaccess:


#RewriteRule ^([A-Za-z0-9\_\-]+)$ http://%{HTTP_HOST}/pg/profile/$1  [R]
#RewriteRule ^([a-zA-Z0-9_-]+)$ pg/profile/$1
#RewriteRule ^([a-zA-Z0-9_-]+)/$ pg/profile/$1

But I just discovered the methods makes visiting administration imposible by forwarding to

domain.blah/profile/admin

I was wondering if there is a workaround ... there could be any solution that actually makes urls shorter (not just forwarding) and has the exceptions in mind...

  • that htaccess trick was written for older elgg vers which had /pg/... uri`s to rewrite. curr elgg @ 1.8 has dropped the /pg prefix and so elgg<profielname> now conflicts with any elgg uri that has a single 'word' which could have been a profile, but now is ambiguous and so --> elgg/admin (and any other similar uri) gets  trashed ;-) a few well-witten RewriteCond`s should fix exceptions. havealook @ http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html and http://httpd.apache.org/docs/2.0/misc/rewriteguide.html for some expert guidance to do this.

     

  • Dhrup. Can there be an extension added to the profile like from

    site.com/mikesplace to

    site.com/mikesplace/123456

    Whereby there are more than one profile mikesplace because they all have an extension or digits in a separate field, let's say a zip code.

     

  • @billy:

    yew bin aroudn elgg longg enuff 2 oughta know that *anything can be coded, just sometimes some things needs some little moare time , effort, etc ;-) and even htaccess rwerutes are powerful enough for fancy logic without going into php code ;-P

  • @DhrupDeScoop Now I know u are a bit expert here on elgg coz I remember in one post we had a light fight lol, I am sure if u spend time u can find out how to do mydomain.com/username for elgg 1.8.8 PLEASE HELP !!!

  • @kisssssss4ever the short user url is very important to me as well. I will try to share everything as I go and hope to receive further help from @DhrupDeScoop. I think at this point we can take two routs. One is to find a way to make exceptions work from inside .htaccess But it doesn't really change url address and its just forwarding. The other rout is to see if we can manipulate elgg through php. I looked under the hood and I discovered that profile is a plugin and in the start.php:

    // main profile page
        $params = array(
            'content' => elgg_view('profile/wrapper'),
            'num_columns' => 3,
        );

    going the .htaccess route I have come up with this (but still it doesn't work):

    #trim /profile making shorter urls with just user name
    RewriteCond %{REQUEST_URI} !^/admin/
    RewriteRule ^([A-Za-z0-9\_\-]+)$ http://%{HTTP_HOST}/pg/profile/$1 [R]

     

  • @Dean I am glad to see your reply, looks like at least u have better knowledge than me. But please keep trying to find out that secret how to make url shorts. I am sure u can do that if u spend time on that. 

    I am waiting for the good news, good luck Dean and DhrupDeScoop and other friends, please make it possible.

    Best Regards,

  • @all - i offer no " good news" but -- play fair to yourselves! ;) give yourself some sincere time to learn php, elgg api, htaccess coding properly. start here ==> read, study and learn.. and learn.. then - do.
    @ http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html and http://httpd.apache.org/docs/2.0/misc/rewriteguide.html for some expert guidance to do this.

     

  • Because of Elgg's routing system change in 1.8, this has to be a plugin. You can't accomplish this through .htaccess.

    You would have to write a plugin that hooks into the route, all hook, checks if the route requested is a username and then displays or forwards to the profile page. You would also have to check usernames upon registration so they don't conflict with existing routes. For example, you don't want someone to register a user as "blog" or your site will lose blogs.

    My AnyPage plugin does has of the routing and checking logic already, though it's not for usernames. It's still a good place to look.

  • @Brett can you comment onthe possibility of adding a third set of digits to profile as in my comment.

    I would like to allow for the same to be used multipletimes with a username/profile with a zip code extension. Registration would need to pick up the zip code and eack member would have a zip code added at the end of their profile, be searchable that way, etc.

    Thanks if you have any thoughts!

  • @TahoeBilly - Profiles map directly to usernames, so you'd either have to do something crazy like allow slashes in usernames and then override the profile router to combine the first and second parts, or override the profile plugin to remove the direct username requirement. You'd also have to have the users enter a zip code when they login, or tell them to only use their email addresses. You also have the privacy issue of users exposing their location by simply joining your site. There is probably a better solution for whatever problem you have.