+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: .htaccess redirect

  1. #1
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    .htaccess redirect

    I have a wildcard redirect set for my domain as *.website.com

    I am trying to figure out how I can setup the .htaccess redirect to point correctly

    Subdomain test.website.com
    Files are in website.com/test

    I still want the url at the top to point to test.website.com

  2. #2
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228
    That's just a subdomain..

    Set it up in cpanel.
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  3. #3
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    Re: .htaccess redirect

    It is a wildcard redirect as I said. I have an outside company that creates a client id the id then becomes the subdomain the subdomain is only used to signify their own copy of the site. I have been trying to figure out how to set it up properly so that whatever they type it shows up with the same files but still contains their subdomain in the address.

    The files are all located in /subdomain

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: .htaccess redirect

    If you are talking about an x10 account, I'm pretty sure there is no way to do it.

    Where you have a bit more control over the server, you should be able to do it.
    Nothing is always absolutely so.

  5. #5
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: .htaccess redirect

    What you're trying to do requires a combination of a wildcard subdomain virtualhost and a URL rewriting .htaccess. Unfortunately, setting up a wildcard subdomain requires access to the virtualhosts setup in the Apache configuration, which is only available on a VPS and not free. I don't think it is available on x10premium either, but it may be possible through some more advanced cPanel options.

  6. #6
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    Re: .htaccess redirect

    I have a premium hosting package with the wildcard redirect in place. My issue here is that no one knows the proper way to setup the .htaccess file to only direct one domain name and not the rest that are hosted on my package.

    If you know how to modify the .htaccess file properly im all ears.

  7. #7
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: .htaccess redirect

    Ok, I see now. What are the specifics (file paths, subdomains etc) that need to be redirected and where to?

  8. #8
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: .htaccess redirect

    Are you looking for something like:
    Code:
    # redirect host "test" to "/test" internally, unless URL already begins with "test"
    RewriteCond %{HTTP_HOST} test.website.com
    RewriteCond $1 !^test(/|$)
    RewriteRule ^/?(.*) /test/$1
    Last edited by misson; 07-07-2010 at 06:42 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  9. #9
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: .htaccess redirect

    Quote Originally Posted by misson View Post
    Are you looking for something like:
    Code:
    # redirect host "test" to "/test" internally, unless URL already begins with "test"
    RewriteCond %{HTTP_HOST} test.website.com
    RewriteCond $1 !^test(/|$)
    RewriteRule ^/?(.*) /test/$1
    Except that 'test' can be any string.
    Nothing is always absolutely so.

  10. #10
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: .htaccess redirect

    I thought driveflexfuel wrote he only wanted to redirect a single subdomain. For mapping all subdomains to sub-directories, perhaps something like:
    Code:
    # ensure that subdomain refers to an existing sub-directory
    RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
    RewriteCond %{DOCUMENT_ROOT}/%1 -d
    RewriteRule ^ - [C]
    
    # map subdomain to sub-directory if not already present in URL
    RewriteCond %{HTTP_HOST} !^(www\.)?website\.com$
    # get the subdomain name
    RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
    # don't add subdir if already present
    RewriteCond %1/$1 !^([^/]+)/\1
    RewriteRule ^/?(.*) /%1/$1
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. .htaccess redirect subdomain help please
    By booksgo in forum Programming Help
    Replies: 3
    Last Post: 02-18-2010, 11:05 AM
  2. .htaccess redirect
    By driveflexfuel in forum Programming Help
    Replies: 3
    Last Post: 02-03-2010, 02:41 PM
  3. Use .htaccess to redirect everyone except you
    By ah-blabla in forum Tutorials
    Replies: 5
    Last Post: 10-14-2009, 05:02 AM
  4. .htaccess redirect with regular expressions
    By Scoochi2 in forum Programming Help
    Replies: 0
    Last Post: 08-25-2008, 07:07 AM
  5. .htaccess 301 redirect help
    By skeets in forum Programming Help
    Replies: 6
    Last Post: 05-04-2008, 08:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers