Results 1 to 5 of 5

Thread: .htaccess 301 redirect

  1. #1
    Join Date
    Apr 2008
    Location
    Little Office!
    Posts
    80
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default .htaccess 301 redirect

    ok,

    here is the code most of the SEO companies prefer to have so that users using the site without www should be redirected to www

    HTML Code:
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^domain.com [nc]
    rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
    but when a user tried to open up domain.com/blog he gets redirected to www.domain.com and not the /blog page he was suppose to be.

    so, is there a way where we can use 301 redirect but also keep them landing to the url they entered???

    Thanks in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Try this:
    Code:
    rewriterule ^(.*)$ http://www.domain.com/{request_uri} [r=301,nc]
    Not sure if it will work, but I think it might...



    EDIT: Actually, I think your problem may be that you need to escape the dots in the domain:
    Code:
    RewriteEngine on
    RewriteCond %{http_host} ^domain\.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,NC]
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    chetanmadaan (08-06-2010)

  4. #3
    Join Date
    Apr 2008
    Location
    Little Office!
    Posts
    80
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    nop!

    any other guesses?

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You replied to my post quickly. Did you notice my edit? I added another option.

    I'm only guessing based on my limited experience with .htaccess. I'm no expert with it either.

    Maybe if you tried to combine the two methods above it would work.

    Alternatively, there should be plenty of info on google about "htaccess www redirect" but I don't see any typos here, but maybe in comparing it to a tutorial you'd find it.
    Last edited by djr33; 08-06-2010 at 04:05 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #5
    Join Date
    Apr 2008
    Location
    Little Office!
    Posts
    80
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    OK.

    sure.. Thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •