Need .htaccess upgrade advice

Discussion in 'Apache' started by PHP Bear, Jan 10, 2012.

  1. #1
    I just did a major hardware/software upgrade - first new computer in 6 1/2 years, new MAMP upgrade, etc. In the process, I jumped from Apache 2.0.59 to Apache 2.2.21. (I haven't upgraded Apache on my online webhosts yet; I want to get everything squared away on my computer first.)

    Anyway, can anyone tell me how I should update my .htaccess files?

    Below is an example of my files. This particular example is a little unusual in that the website's home page itself functions as a dynamic page. In other words, there are About and Topics sections (MySite/About, MySite/Topics) with dynamic pages (e.g. MySite/Topics/Roses), but dynamic pages can also be displayed off the home page (e.g. MySite/Planets, MySite/Stars).

    I should also add that I prefer that trailing slashes NOT be displayed. It causes some confusion in my stats, where I get so many hits for Topics/Roses and so many hits for Topics/Roses/. I'd like to direct all the traffic to Topics/Roses.

    If you see anything else I should change (or add) I'm all ears (or eyes). I never did have a good understanding of Apache. Thanks!

    * * * * *

    Yikes, I can't seem to post the code, so I'm going to create a line break after each line...

    RewriteEngine On
    # Add /? before first $ in every row if you want optional trailing slashes.
    RewriteEngine On
    RewriteRule ^test\.htm$ test.php [L]
    Options -MultiViews


    # php_value magic_quotes_gpc 0
    php_flag magic_quotes_gpc Off


    RewriteRule ^About/([a-zA-Z0-9()_/-]+)/?$ About/index.php?bout=$1 [L]
    RewriteRule ^Topics/([a-zA-Z0-9()_/-]+)/?$ Topics/index.php?topic=$1 [L]
    RewriteRule ^/?([-a-zA-Z0-9_/]+)/?$ /index.php?area=$1 [L]
     
    PHP Bear, Jan 10, 2012 IP