MSFN Forum: .htaccess Subdomains - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

.htaccess Subdomains Rate Topic: -----

#1 User is offline   gamehead200 

  • SEARCH!!! SEARCH!!!
  • Group: Super Moderator
  • Posts: 7,035
  • Joined: 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 19 May 2004 - 06:41 PM

For those of you that run little webservers at home and that don't have cPanel (:D), here is a nifty trick that will allow you to create your very own subdomains...

FOR APACHE ONLY! IIS DOES NOT SUPPORT THIS!

First off, say you want http://msfn.yoursite.com to redirect to http://www.msfn.org, then you would put the following in the .htaccess file in the root of your server:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^msfn.yoursite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.msfn.yoursite.com$
RewriteRule ^(.*)$ http://www.msfn.org/ [L,R=301]


This basically redirects it to msfn.org! :rolleyes:

And now, let's say you want a random subdomain to redirect to a random folder on your server... For example, let's say you type in http://something.yoursite.com in your browser... This rewrite rule should make it redirect to http://www.yoursite.com/something ... Now if you do or do not have a folder called "something" on your server, that's another story. If its there, it'll redirect, it if its not, it'll give you a 404! :)

RewriteEngine On

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


The %1 is a variable, so therefore whatever gets placed before .yoursite.com will be in place of that variable.

If anyone has any suggestions or comments, post them here and i'll be glad to help out! :D


#2 User is offline   XtremeMaC 

  • MSFN SuperB
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,070
  • Joined: 13-October 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 19 May 2004 - 11:15 PM

wow nice
every day u get closer to be a pro in this web business :)

#3 User is offline   Carmon 

  • MSFN's Local Mental Case
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,598
  • Joined: 08-June 03

Posted 21 May 2004 - 01:07 AM

Everyday dat **** Canada Gameshead get clever must kill him lol :D

:rolleyes: jk how u access the .htaccess file? :)

#4 User is offline   gamehead200 

  • SEARCH!!! SEARCH!!!
  • Group: Super Moderator
  • Posts: 7,035
  • Joined: 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 21 May 2004 - 05:33 AM

Widnez_boy, on May 21 2004, 03:07 AM, said:

Everyday dat **** Canada Gameshead get clever must kill him lol :D

:rolleyes: jk how u access the .htaccess file? :)

If you're using Linux, I believe you need to unhide it since files that start with "." are hidden...

If there isn't one presently on the server, you can send it via FTP... Make the file with Notepad! :D

#5 User is offline   shortiee4 

  • Group: Members
  • Posts: 1
  • Joined: 27-October 04

Posted 27 October 2004 - 09:21 PM

I can't seem to get a subdomain working with my domain i tried using the .htaccess file but it still doesn't work. Do I need to register the subdomain with dns or anything? i'm confused could someone walk me through how to do this?

#6 User is offline   newdarkness 

  • Group: Members
  • Posts: 1
  • Joined: 12-December 04

Posted 12 December 2004 - 05:59 PM

Hello,
When I am making this .htaccess for my page, it is working, but suddenly all directories of my server need authentification, what should I do?

#7 User is offline   matrix0978 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 814
  • Joined: 17-August 04
  • OS:none specified
  • Country: Country Flag

Posted 10 January 2005 - 02:05 AM

shortiee4, you might just want to add and subdomain from your host...If not the host might now let you have subdomains. But if its off you computer then i dont know. Youll have to ask Gamehead For that one.! :thumbup

#8 User is offline   murtuzahsn 

  • Group: Members
  • Posts: 1
  • Joined: 02-March 10
  • OS:XP Pro x64
  • Country: Country Flag

Posted 02 March 2010 - 01:36 AM

Thanks for such a great post. I have added the following line in my htaccess file:

RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.mywebsite\.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite...oller/action/%1 [L]

When i give the above, the page content is showing what i was expecting, but the problem i am facing is the page URL is also getting changed. I dont want that. What should i do? Is there something in the server that needs to be done? Please suggest.

I am working with CakePHP

Thanks.

View Postgamehead200, on 19 May 2004 - 06:41 PM, said:

For those of you that run little webservers at home and that don't have cPanel (:P), here is a nifty trick that will allow you to create your very own subdomains...

FOR APACHE ONLY! IIS DOES NOT SUPPORT THIS!

First off, say you want http://msfn.yoursite.com to redirect to http://www.msfn.org, then you would put the following in the .htaccess file in the root of your server:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^msfn.yoursite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.msfn.yoursite.com$
RewriteRule ^(.*)$ http://www.msfn.org/ [L,R=301]


This basically redirects it to msfn.org! ;)

And now, let's say you want a random subdomain to redirect to a random folder on your server... For example, let's say you type in http://something.yoursite.com in your browser... This rewrite rule should make it redirect to http://www.yoursite.com/something ... Now if you do or do not have a folder called "something" on your server, that's another story. If its there, it'll redirect, it if its not, it'll give you a 404! :lol:

RewriteEngine On

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


The %1 is a variable, so therefore whatever gets placed before .yoursite.com will be in place of that variable.

If anyone has any suggestions or comments, post them here and i'll be glad to help out! :D


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy