Custom URL Trick

16 years 4 months ago #52085 by jeffason
Custom URL Trick was created by jeffason
Custom URL Trick

Here is just a useful post

I have already been able to get custom urls working like www.domain.com/username .

I can now also do username.domain.com

1) make sure there is a *.domain.com entry in your DNS settings

2) put this in your .htaccess. This is for www.domain.com/username AND username.domain.com. It should also be known that I modified comprofiler.php to show 404 header when no profile is found.

RewriteCond %{HTTP_HOST} !^www\..+ [NC]
RewriteCond %{HTTP_HOST} ^(.*)\\.(.*).*\.com [NC] * NOTE BELOW *
RewriteRule !..* http://www.%2.com/%1 [NC,R,L]

RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see ##notes##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?option=com_comprofiler&task=userProfile&user='$1' [L]

The only issue is that you will not be logged into username.domain.com if you login to www.domain.com, and visa versa. [NC,R,L] is a fix. If you change it to [NC,P,L], you will need to login twice, but you keep the url in the browser.

Also, no spaces etc are allowed in username.domain.com

* NOTE *
THIS MAY NOT WORK BECAUSE THE FORUMS ARE REMOVING A LEADING BACKSLASH BEFORE A . IN BETWEEN THE TWO (.*)'s

3) Modify the comprofiler.html.php file and add this:
var r = new RegExp("[^a-zA-Z0-9]", "i");

It needs to be added in two areas

This will make it so users must only use letters or numbers and no spaces - perfect

Post edited by: jeffason, at: 2007/12/09 23:08

Please Log in to join the conversation.

16 years 4 months ago #52195 by mrinaljena
Replied by mrinaljena on topic Re:Custom URL Trick
1) make sure there is a *.domain.com entry in your DNS settings


do u know where and how to set this?

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.180 seconds

Facebook Twitter LinkedIn