0
Welcome Guest! Login
0 items Join Now

Redirect http://yoursite.com to http://www.yoursite.com

    • 's Avatar

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • Leckenby's Avatar
    • Leckenby
    • Elite Rocketeer
    • Posts: 714
    • Thanks: 0

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • As in you have a subdomain and its folder is in public_html? I wouldnt do a rule, I would just move it outside of the public_html and make you subdomain look there, then only subd.mydomain.com would work.

      Thats what I did with cpanell 11
    • 's Avatar

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • I dont follow you. I created those subdomains with cpanel and they are physically in subfolders of /public_html/ so they are accessible either via subdomain.domain.com and www.domain.com/subdomain/ and domain.com/subdomain/

      I have found these rules that work NICE for me so far :


      Options +FollowSymLinks
      RewriteEngine on
      # Remove "www." from any subdomain requests
      # (Same rule will work for all subdomains)
      RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.mysite\.com [NC]
      RewriteRule (.*) http://%1.mysite.com/$1 [R=301,L]
      #
      # Redirect client subdirectory requests to subdomain
      # (Does not affect internal rewrites. One ruleset is required per subdomain)
      RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com [NC]
      RewriteCond %{THE_REQUEST} ^[A-Z]+\ /subdomain1/
      RewriteRule ^subdomain1/(.*) subdomain1.mysite.com/$1 [R=301,L]
    • Last Edit: 16 years 10 months ago by Moinon.Loic.
    • Leckenby's Avatar
    • Leckenby
    • Elite Rocketeer
    • Posts: 714
    • Thanks: 0

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • yeah, but what I am saying is, in Cpanel (depending on the version), you can select where the roots of the subdomains are located. So instead of locating them in say public_html, you could put the roots in:

      home/subdomains/subdomain1 or whatever - then they can only be accessed by subdomain1.mysite.com or w/e

      See what I mean? Much better for managing your website to I would say!
    • 's Avatar

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • Right but for security reasons, it is usually advisable to have these content folders in /public_html ?
    • Leckenby's Avatar
    • Leckenby
    • Elite Rocketeer
    • Posts: 714
    • Thanks: 0

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • I don't think so, why should it cause security problems?
    • 's Avatar

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • I am not an expert but there are some option with WHM that prevent scripts from running out of /public_html/ for instance.
    • Leckenby's Avatar
    • Leckenby
    • Elite Rocketeer
    • Posts: 714
    • Thanks: 0

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 10 months ago
    • Ive had joomla running on my subdomains, which are outside the public_html
    • guysmiley's Avatar
    • guysmiley
    • Sr. Rocketeer
    • Posts: 160
    • Thanks: 2

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 7 months ago
    • Andy Miller wrote:
      I had this asked a couple of times, so here's how you do it in your .htaccess file:
      RewriteCond %{HTTP_HOST} !^www.yourhost.com$ [NC]
      RewriteRule (.*) http://www.yourhost.com/$1 [R=301,L]

      I know this is an extremely old post, but if I invoke this script in .htaccess and enter mydomain.com in the address bar, should I then see this address get replaced with www.mydomain.com when I hit <ENTER>?
    • Leckenby's Avatar
    • Leckenby
    • Elite Rocketeer
    • Posts: 714
    • Thanks: 0

    Re: Redirect http://yoursite.com to http://www.yoursite.com

    Posted 16 years 7 months ago
    • correct

Time to create page: 0.052 seconds