+ Reply to Thread
Results 1 to 5 of 5

Thread: Did I make any mistake with .htaccess?

  1. #1
    ucdbbs is offline x10Hosting Member ucdbbs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    32

    Did I make any mistake with .htaccess?

    I tried to redirect my subdomains to the directory under public_html.

    Nothing works with the following .htaccess.

    Code:
    RewriteEngine on
    RewriteCond %{http_host} .
    RewriteCond %{http_host} !^www.mydomain.com [NC]
    RewriteCond %{HTTP_HOST} ^(.*).mydomain.com [NC]
    RewriteRule ^(.*)$ http://mydomain.com/%1/$1 [R=301,L]
    Did I miss any point here?

  2. #2
    adamparkzer is offline On Extended Leave adamparkzer is just really nice
    Join Date
    Jun 2008
    Location
    IL, USA
    Posts
    3,745

    Re: Did I make any mistake with .htaccess?

    Moved from Free Hosting Support to Programming Help.

    - Adam

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

    Re: Did I make any mistake with .htaccess?

    Quote Originally Posted by ucdbbs View Post
    Code:
    RewriteCond %{http_host} .
    "." matches any one character, so this condition is always true when HTTP_HOST is set. Given the 3rd RewriteCond, this line adds nothing.

    Lower-case server variable names may or may not work. The documentation only ever shows them as upper case. Best not to tempt fate.

    Quote Originally Posted by ucdbbs View Post
    Code:
    RewriteCond %{http_host} !^www.mydomain.com [NC]
    RewriteCond %{HTTP_HOST} ^(.*).mydomain.com [NC]
    RewriteRule ^(.*)$ http://mydomain.com/%1/$1 [R=301,L]
    Here you're not redirecting "www.mydomain.com" to "mydomain.com". Is this on purpose? Usually people either force or remove the "www". I can't tell exactly what you want since you weren't very explicit in your post.

    Technically, you should be escaping the "." metacharacters in the RewriteCond when you don't want them to function as metacharacters. Since host names have only a few expected values, not escaping the "." shouldn't cause problems.
    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.

  4. #4
    ucdbbs is offline x10Hosting Member ucdbbs is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    32

    Re: Did I make any mistake with .htaccess?

    Hi,

    I wish to redirect all "subdomains.mydomain.com/blabla..." request except "www.mydomain.com" to
    "http://mydomain.com/subdomains/blabla..."

    That's why I used "!^www."

    So, do you mean I should try
    Code:
    RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
    Yes. I've tried this on my website hosted at lotus.x10hosting. But it just didn't work.

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

    Re: Did I make any mistake with .htaccess?

    What are the actual lines in your .htaccess? What URL are you trying and what is the result?
    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

Similar Threads

  1. Principles of Influencial Business
    By supportfreedom in forum Earning Money
    Replies: 8
    Last Post: 08-28-2009, 01:01 PM
  2. Replies: 0
    Last Post: 08-18-2009, 08:06 AM
  3. Replies: 7
    Last Post: 06-10-2008, 09:12 AM
  4. Replies: 1
    Last Post: 03-06-2008, 06:15 AM
  5. default .htaccess
    By Fedlerner in forum Computers & Technology
    Replies: 9
    Last Post: 09-05-2007, 09:10 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