short url with profile name with .htaccess

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


There are several posts discussing this:

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


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...

  • @'all

    *    As mentioned above -- All those notes on (  /pg/ styled ) htaccess *were during < 1.8.x release
          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... (the ' routing system change in 1.8 that Brett refers to.)
          "register a user as "blog" or... -> the same problem was met < v1.8 w/ (isolated)  "search" URI's -
          which someone then coded a work-around for.

    *    The 1.8 'routing changes' -- pretty much changes the landscape for the whole game
          (the now cheaper htaccess trick may work now - in some cases only).

    !     I think what Billy wants is to shortcut/quickly-goto user profiles in his flavor of (his orientation of
          Elgg-Site CustomizationS - where ZipCodes are not quite 'privacy issues - but a taken-for-granted
          part of the whole set-up -- to allow fast locating of (his Site's) Users - more like locating Users
          via location (zipcodes) in other use-cases. And.. my 75¢ answer;-) => Sure - can be done via
          the routing extensions, with the necessary code to handle the special case(s).
    !     and btw - this is kinda a very old topic, since abt 3 years back ;-)
; when much was being
          discussed re so-called 'PermaLinks' then.
    !     Elgg 1.8 API changes / enhancements does make certain many things different / easier as in
          this case.


  • @ Brett - Thank you for your feedback! And a slash or dash might work fine too!

    @ Dhrup - about privacy issue, correct, in fact I want Google to pick up the zip codes! In a perfect world the members title name would the URL, not the user/login name so- or

    where login is FastFreddy or email what have you.



  • So many replies , reading them and brain goes funny...but still I can not understand what to do.... and how to do....

  • @Tahoe: Your example of; implies a mixed scanario - you could be looking for permalinks via 'profile name' or via 'zipcodes' or both. In each case - my (now outdated, written @ early 2009!;) original htaccess hack rewrite will not work as it did with earlier Elgg versions - you'd have to code maybe several thousand lines of extra php! no joke.

    The only way to make that work now @ 1.8 -- would to code a few thousand lines of unnecesary code -- how many reWriteCond`s do you want ?? -- to support the essentially cheap hack kiddie trick. On the other hand - a proper hook into Elgg's routing mechanism will take approx 10 lines of coding in php (believe - i've counted my proof of thought plugin coderight here, on my desk, first thing in the morning! & lolz)

    Now - if those ZipCodes were Groups, Blogs, other entitiy types - then a few more lines of logic will bring in re-routing to your Groups, Blogs or whatevers. How much woulddja Users pay to have their pizza hangout be Permalinked as BillyTahoe.Com/90210&nbsp; actually pointing to Group / Blog owned by your User ?? starts to make sense in the different and correct perpectives.

    My half-s 110% guess is that any entity type, subtype should be amenable to PermaLinking within Elgg - and this should take only some mickey-mouse code that traps and checks :-
            goto to profile
            goto to group
            goto to blog
            goto to album

    ...yadda, yadda, ad nauseum to your liking.. I'll try out some test code to see how that swings and soooo starts to mean something.