More advanced mod-rewrite

    Date: 11/16/07 (Apache)    Keywords: php, html, web, hosting

    I've recently been switching my site over from a bunch of static HTML pages to PHP using Smarty templating

    I've decided to use mod_rewrite to make more attractive and search-engine friendly canonical URLs

    I've chosen this format:

    http://example.com/some-words/some-more-words/
    http://example.com/some-words/
    (both are valid, up to 2 such sections as shown)


    Notice no ".html"/".php". This is rewritten to

    index.php?page=some-words/some-more-words/


    The problems:

    In the meantime, while I transition to this format, I'm keeping my old static pages up, because there's a lot of inbound links to them that aren't going to get changed (little websites, various forum and blog posts, etc)

    I'll eventually get my pages switched over, but in the meantime there's at least one directory I would like to exclude from rewriting. Is there a way I can omit specific URLs from rewriting? I'd like for "example.com/particular-directory/" to be exempt from being rewritten

    Another possibly related problem is that I have a few other domains hosted as "add-on" domains to the same hosting package, so their contents are in a subdirectory. So, of course, the URL re-writing directive cascades down and breaks those domains completely. Of course, it only took a few seconds to fix by adding an .htaccess to each subdirectory saying "RewriteEngine Off", but what if I wanted a separate URL-rewriting scheme on those directories? Can I tell it to ignore any other rules that might be applied and start fresh?


    My current rewriting rule looks like this:

    RewriteEngine On
    RewriteRule ^/?([a-zA-Z0-9\-]+/?[a-zA-Z0-9\-]+/?)$ index.php?page=$1 [L]


    Is there a flag or other rules that could help me?

    (Note: I'm on shared hosting so http.conf etc are not an option)

    Source: https://apache.livejournal.com/39655.html

« Newb question about Struts2... || "You don't have... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home