NameSilo

[Resolved] How to do what del.icio.us does?

Spaceship Spaceship
Watch

Miyavi

o-re-sa-maVIP Member
Impact
41
How to do what del.icio.us does?

Hello,

I'm assuming this is all done in the .htaccess file(s), but I could be wrong. Hopefully someone can help.

For example, let's say I own 123.com and want my subdomain to be abc. So, I go into cPanel and create my subdomain. In my FTP, I now have two folders: one for 123.com, and one for abc.123.com
What I want is for abc.123.com to essentially become the main site--not 123.com
If you need clarification of what I'm asking, notice that when you type http://www.icio.us, no site exists; however, when you type http://del.icio.us, well... ;)

How do I go about doing the same thing? I'm sure it's simple and I apologize for my ignorance in the matter, but I've never really dealt with subdomains before.

Thanks. :tu:
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
No need for any htaccess you just simply promote that sub domain rather than the main domain. If you really wanted too you could do a rewrite rule to forward the normal domain to the sub domain.

In the case of icio.us they have DNS set up but the connection does not get accepted. Personally I think this is a waste of traffic why don't they just forward to the sub domain.
 
Last edited:
0
•••
0
•••
why that is a waste of traffic. Anyone coming to the domain name would be lost. Why not forward them to the sub domain?
 
0
•••
Suppose so. Was just interested in knowing how to do it. However, I guess I'll go your route. But...

I use add-on domains with cPanel, so for those of you familiar with how that works, let's say the domain name I receive hosting with is nemesisxg.com, and the add-on domain is 123.com
What I now need is for my .htaccess file to redirect to abc.123.com whenever any of the following URLs are entered:
www.123.nemesisxg.com
123.nemesisxg.com
www.123.com
123.com

What should my .htaccess file look like? Something like the following I suppose, but I don't know the minor details to make it work correctly. For example, I think I need some [OR]'s in there/etc:

Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^123.nemesisxg.com$
RewriteCond %{HTTP_HOST} ^www.123.nemesisxg.com$
RewriteCond %{HTTP_HOST} ^www.123.com$
RewriteCond %{HTTP_HOST} ^123.com$
RewriteRule ^(.*)$ http://abc.123.com [R=301,L]

I also want to include the following bit of code (or something similar) in there so that the www never shows up in the url (I want abc.123.com, not www.abc.123.com):

Code:
RewriteCond %{HTTP_HOST} ^www\.(.*) [nc]
RewriteRule ^(.*)$ http://%1/$1 [r=301,nc,l]

How should I put it all together most effectively? Any help will be much appreciated and a rep sure to follow.

Thanks. :tu:
 
0
•••
50 NP$ and a positive rep to the first person who helps me get this right.
 
0
•••
Remove www:

Code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.your\.site\.us$ [NC]
RewriteRule ^(.*)$ http://your.site.us/$1 [R=301,L]

Simply use a redirect header for the different pages. Typically

PHP:
header("Location: http://your.site.us",TRUE,301);

To make all pages under / go to index.php try

Code:
RewriteRule .* /index.php [R=301,L]

Not tested. Small adjustments may be needed.
 
0
•••
So how exactly do the header redirects work? I'm looking to accomplish the redirects through the same (or at least similar) method as I've posted above (unless it's going about things the completely wrong way).

Due to my complete lack of knowledge regarding .htaccess files, ideally I'd like to have the full code posted for what needs to be in my .htaccess file. If this isn't possible, I guess I'll continue to fiddle around with things on my own later on.

Appreciate your response. Thanks. :tu:
 
0
•••
you could simply have the following in your htaccess to direct to the correct subdomain:-

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^sub.domain.com]$
RewriteRule ^(.*)$ http://sub.domain.com [R=301,L]

This forwards anything that is not sub.domain.com to http://sub.domain.com and uses a 301 redirect so that search engines etc know there is no content on the particular URL they were trying.
 
0
•••
0
•••
This code should remove www.

Code:
RewriteCond %{HTTP_HOST} ^www\.your\.site\.us$ [NC]
RewriteRule ^(.*)$ http://your.site.us/$1 [R=301,L]
 
0
•••
Do I add it below the code Peter already provided? Do I use it instead? Either way, not working as of yet. Still showing the www

Also, should the the .htaccess be in my main site folder, or in the subdomain folder? Again, I've tried both and it's still not working.

Bit of a pain, yeah? ;)
Thanks.
 
0
•••
the htaccess should be in the folder for your main domain not the subdomain.

Is the code I provided the only content of your .htaccess file? I can't see any reason why it should forward too http://www.sub.domain.com
 
0
•••
Perhaps has something to do with the fact it's an add-on domain in cPanel? I don't know. Awful frustrating, yeah? :(

Edit:
Will get in touch with host tomorrow and see if I/we can figure this out. I'll keep you posted.
 
Last edited:
0
•••
0
•••
Host not going to help with this. They don't bother with coding issues I guess.

Anyway, I think I may have an idea as to what the problem is:
In my main site's .htaccess, I tell it to always use the www version with the following code:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...so perhaps it is forcing my add-on domain to always use the www version as well since this .htaccess file is global? I tried removing it to check, but unfortunately, the www STILL showed up with my add-on domain... so perhaps this isn't the problem after all? Wish I knew what's wrong...

Increasing my offer to 100 NP$, possibly more, if someone is able to get things working.
 
0
•••
0
•••
PM me with details and a login, I'll attempt to do this for you later if you like. :tu:

Dan
 
0
•••
Host was able to fix it for me. They had no intention of doing so at first, but ended up looking into it after my reply. All is working now.

Not exactly sure how they fixed it, but I'll post the code so that perhaps someone else in the same situation can find help in the future.


This .htaccess file goes in your addon domain folder:
Code:
Options +FollowSymlinks
RewriteEngine on
#RewriteCond ^$ [NC]
#RewriteRule ^(.*)$ http://subdomain.addondomain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.addondomain.com [NC]
RewriteRule (.*) http://subdomain.addondomain.com/$1 [R=301,L]

This .htaccess file goes in your addon's subdomain folder:
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.subdomain.addondomain.com
RewriteRule ^(.*)$ http://subdomain.addondomain.com/$1 [R=permanent,L]

Make sure to replace subdomain and addondomain with your own details. Should work.

Thanks to all who took the time to try and help. Much appreciated. :tu:
 
Last edited:
0
•••
Or, you could just tell your webhost to change your main domain to your subdomain, and you would forward the subdomain via A record at your registrar to the cPanel account.

-Frikkle :)
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back