tastypuppies (tastypuppies) wrote in apache,
tastypuppies
tastypuppies
apache

More advanced mod-rewrite

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)
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 3 comments