1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

With and without WWW

Discussion in 'HTML & Website Design' started by nadlay, Jun 20, 2004.

  1. wakeup

    wakeup Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    The reply was for you.

    I have just tried it, I have put it in my root htaccess file, and it is the same result. It redirect hhdirecto.net/breakdance to www.hhdirecto.net/breakdanc, but Don't redirect hhdirecto.net/letras to www.hhdirecto.net/letras because letras have another .htacces file

    RewriteEngine On
    RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1
    RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1
    
    Code (markup):
    :(
     
    wakeup, Mar 13, 2006 IP
  2. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #22
    Try placing it in that htaccess file instead, but after the existing code you've shown above - let us know how it goes.
     
    Tam, Mar 14, 2006 IP
  3. wakeup

    wakeup Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    neither :(

    I have just tried this in my forder .htacces file
    RewriteEngine On
    RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1
    RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1
    RewriteCond %{HTTP_HOST} ^([^.]+\.net) [NC] 
    RewriteRule (.*) http://www.%1/$1 [R=301,L]
    
    Code (markup):
     
    wakeup, Mar 14, 2006 IP
  4. dealsway

    dealsway Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #24
    Hi Tam,

    I used your code ,

    it doesn't seem to redirect the files without www init.

    what could be the issue?
     
    dealsway, Mar 17, 2006 IP
  5. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #25
    hmmm, looks as though you are running some sort of script?

    Since I don't know the script, or if you can configure it to point to www.yourdomain, maybe it would be easier to place that script in a subdomain and use the original htaccess for your main domain?
     
    Tam, Mar 17, 2006 IP
  6. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #26
    You need to place it in your main web folder (often 'public_html'), maybe you have placed it somewhere else? Does your host allow you to use htaccess?

    Just a quick explanation of what it does ...


    RewriteCond %{HTTP_HOST} ^([^.]+\.com) [NC]
    Code (markup):
    This line checks to make sure it's not a www or subdomain request, before running the next line ...

    RewriteRule (.*) http://www.%1/$1 [R=301,L]
    Code (markup):
    This line redirects the request to the corresponding page but with the www prefix.
     
    Tam, Mar 17, 2006 IP
  7. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #27
    As a matter of interest what was the result? The same as your previous post or in some way different?
     
    Tam, Mar 17, 2006 IP
  8. dealsway

    dealsway Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #28
    Hi Tam, it works for folder and its not working for files. so still do you think we are having issue in running .htaccess or we are not in the root of the public_html
     
    dealsway, Mar 17, 2006 IP
  9. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #29
    Can you give any examples?

    I am going to have to go for a while but will try and get back later, failing that, I'll be back in the morning. Sorry about that.

    :)
     
    Tam, Mar 17, 2006 IP
  10. dealsway

    dealsway Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #30
    My hosting poeple also not sure why the code is not working.

    Can you guys tell me whether the following code is okay so that i can make sure that this is done with all our files.

    if($_SERVER["HTTP_HOST"] == "domain.com") {
    $URI = $_SERVER["REQUEST_URI"];
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.domain.com$URI" );
    exit();
    }
     
    dealsway, Mar 18, 2006 IP
  11. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #31
    Yes that works, but don't forget to change the domain.com element to your own domain. Its also a search engine friendly way of doing it, apparently. You just have to place it at the very beginning of every page, and every page has to be a .php page

    Glad you sorted it :)
     
    Tam, Mar 18, 2006 IP
  12. dealsway

    dealsway Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #32
    yes, all are PHP files and i was lucky that i had a common file which was included in all our PHP files as first file, so i just put this code and everything went well.

    now both for folders and for files we are having the 301 redirect.
     
    dealsway, Mar 18, 2006 IP
  13. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #33
    That's great!

    Look forward to seeing how things are going in the future, good luck m8 :)
     
    Tam, Mar 18, 2006 IP
  14. dealsway

    dealsway Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #34
    Sure, i will share the results soon.
     
    dealsway, Mar 18, 2006 IP
  15. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #35
    I should have added to my other post, that htere is a way to force your server to read html files as php files, but that also relies on an htaccess entry, so that may or may not be available to you (just as the problem with the htaccess mod_rewrite we tried before).

    If you want to try that at any time just add the following to the top of your htaccess file ...

    AddType application/x-httpd-php .html
    Code (markup):
    :)
     
    Tam, Mar 19, 2006 IP
  16. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #36

    I have just used this thanx it work great, just the job. :)
     
    johneva, Mar 19, 2006 IP
  17. wakeup

    wakeup Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #37
    What kind of script have I to search? php script?
     
    wakeup, Mar 20, 2006 IP