SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    CA
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod Rewrite - confusing

    I have a site to a directory with a URL that looks like this:

    http://filipinaeyes.com/online-dating-gallery

    I need to rewrite the above url so it has the www and looks like this:

    http://www.filipinaeyes.com/online-dating-gallery

    My htaccess file is in the online-dating-gallery directory.

    My research turned up two suggestions but not sure which is correct or maybe they both are wrong.


    MY HOST SUGGESTION:

    Code:
    RewriteCond %{HTTP_HOST} ^filipinaeyes\.com
    RewriteCond %{HTTPS} =on
    RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
    RewriteCond %{HTTP_HOST} ^filipinaeyes\.com
    RewriteCond %{HTTPS} !=on
    RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
    MY FRIENDS SUGGESTION:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^filipiniaeyes.com/online-dating-gallery [NC]
    RewriteRule ^(.*)$ http://www.filipiniaeyes.com/online-dating-gallery/$1 [L,R=301]
    In the above code, not sure if Options +FollowSymLinks is needed or not.

    Not sure what damage can be done to my search engine ranking if I get it wrong, so I would appreciate any feedback from the experts at sitepoint.

    Thank You

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,892
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    From the Apache website:

    FollowSymLinks
    The server will follow symbolic links in this directory.
    Note: even though the server follows the symlink it does not change the pathname used to match against <Directory> sections.
    Note: this option gets ignored if set inside a <Location> section.

    In other words, if you have symlinks in the directory and want apache to use those, you can use Options +FollowSymLinks
    If you don't have symlinks in the directory you can easily leave this out.

    As for the rewriterules, I would go with the one your host suggested, since the one your friend suggested doesn't work. He's matching HTTP_HOST against filipiniaeyes.com/online-dating-gallery, but the HTTP_HOST does not contain directory information, so in your case it will only contain filipiniaeyes.com, the /online-dating-gallery part can be found in %{REQUEST_URI}.

    In short:
    - If you have symlinks, use Options +FollowSymLinks, otherwise don't
    - Use the solution suggested by your host

    PS. If you don't use https on your site, you can change the rewrites to be
    Code:
    RewriteCond %{HTTP_HOST} ^filipinaeyes\.com
    RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    CA
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your answer....I must admit some of it goes over my head, but you gave me good instructions.

    May I make sure I'm clear on one thing. If I used your rewrite rule, I would

    REPLACE ALL OF MY HOST'S CODE

    RewriteCond &#37;{HTTP_HOST} ^filipinaeyes\.com
    RewriteCond %{HTTPS} =on
    RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
    RewriteCond %{HTTP_HOST} ^filipinaeyes\.com
    RewriteCond %{HTTPS} !=on
    RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]

    WITH YOUR CODE:

    RewriteCond %{HTTP_HOST} ^filipinaeyes\.com
    RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]

    Sorry, wasn't too sure if I replaced all of the host code with your code or only part of it.

    Thanks again

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,892
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    If you use Secure HTTP (https), you need to use the code from your hoster. If you don't you can just as well use my code.
    That way you can skip the check to see if https is enabled, because if you never use it, you already know the answer to that
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    CA
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again ScallioXTX. I appreciate your help.

    lemonzoo, as far as the tutor. I think I seen it before. What may of caused me problem is your tutor addresses the rewrite for your root (home page), but I need the rewrite to work for a directory -- filipinaeyes.com/online-dating-gallery.

    I think when I tried to do it your way, it ended up redirecting my filipinaeys.com/online-dating-gallery to my home page filipinaeyes.com. That's not what i wanted or I do not understand your tutor.

    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
  •