.htaccess and 301 redirects

Discussion in 'Web Design and Development' started by Sdashiki, Oct 26, 2009.

  1. Sdashiki macrumors 68040

    Sdashiki

    Joined:
    Aug 11, 2005
    Location:
    Behind the lens
    #1
    I just had htaccess "turned on" at my free host (110mb.com)...

    Because I switched from .html to .php for alot of my site and want anytime someone hits an old link to get them to the new link. There are links to various pages on my site all over the web and I cant change them all by request to webmasters...

    So, Im trying 301 redirects:

    Code:
    Redirect 301 /index.html [url]http://site[/url]
    This .htaccess file is located in root/polaroid/ so when someone looks for:
    http://site
    they get
    http://site

    Yet this doesnt happen...you can freely navigate to the .html page without an redirection.

    Did my host forget to turn .htaccess on (though their email said it was) or am I configuring this completely wrong?


    ps: no i dont want EVERY .html page accessed to be turned into .php because I still have some .html pages within the site.
     
  2. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    First test determine if they allow you to use .htaccess by simply using a few characters of garbage text in your .htaccess. If you get an Internal Server Error 500 or actually an error of any kind, your .htaccess is at least being processed. Then you start debugging command syntax in your .htaccess, i.e. for your situation you might want to try:

    If nothing happens, a proper .htaccess setup in Apache2's configuration files include:

    • Enabling mod_rewrite module
    • For your directory, make sure "AllowOverride All" and not set to "none"
    • Options FollowSymLinks
    Here is an example of a typical virtual subhost setup in Apache2's virtual host file with .htaccess support enabled:

    Remember they have to restart Apache after making any changes to the configuration on their end.

    Rarely, some webhosts choose a different filename instead of .htaccess for security reasons, so if all else fails ask them if you're using the right filename as a last resort - and remember, this is VERY rare. This is all I can think of to help ya.

    -jim
     
  3. Angelo95210 macrumors 6502a

    Angelo95210

    Joined:
    Jan 7, 2009
    Location:
    Paris, France
    #3
    Here is a line of my .htaccess if it can help :

    Code:
    Redirect 301 /component/option,com_linx/Itemid,93/ /links.php
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    I believe you'll need,
    Code:
    Redirect 301 [B]/polaroid[/B]/index.html http://option8.110mb.com/polaroid/index.php
    as simply placing the .htaccess file into the polaroid folder doesn't make that the new root folder that it's accessing.

    Also be sure to pay attention to SrWebDeveloper's advice for the rewrite engine. You'll be able to simplify how much you have to write for your redirects using that method rather than doing a Redirect line for each page. If you need help just keep asking.
     
  5. Sdashiki thread starter macrumors 68040

    Sdashiki

    Joined:
    Aug 11, 2005
    Location:
    Behind the lens
    #5
    Yeaaaa, a little more research showed me that putting garbage (or anything of bad syntax) would give you a server error and not...nothing.

    So when I tested garbage...nothing happened.

    I dont think they gave me .htaccess yet...(its a lifetime upgrade $9) even though an email 2 days ago said I did because that wasnt the receipt email...it was specific to say:

    «¤»¥«¤»§«
    ¯¯¯¯¯¯¯¯¯
    You now have full access to:

    1) .htaccess files support (in any directory)
    2) .htpasswd files support (in any directory)


    Regardless my new "updated" site took all my pages and removed the header/footer/side menus on both sides (3 column fixed layout) into "include ()" calls to simplify my updates. So only in a few cases will this truly change the syntax of the link from anything but .html>.php

    Where it would change is because for all the subfolders within /polaroid/ i changed the original #1 page for that section to index.php. Example: /polaroid/104/104.1.html became /polaroid/104/index.php

    But besides that, everything else is just .html>.php change.
     

Share This Page