create new tag
, view all tags
mod-rewrite is an Apache module that allows changing of URLs. For example, if you have a website with a long complicated URL, you could [probably | possibly] simplify it by installing the mod-rewrite module and then creating appropriate rewrite rules.

Based on some quick browsing, it also allows you to host more than one web site under a single web hosting account. I think there are other ways to do that as well, like something called something like "virtual domains" or "virtual hosting" (or am I thinking of email servers?).

http://www.modrewrite.com/ seems like a good place to start -- lots of links to other sites.

Any unattributed quotes are from one of the forums at http://forum.modrewrite.com/, most probably from Brett.




Just some tidbits of knowledge as I browse:

  • The rewrite engine basically uses regular expressions to make changes
  • I'm confused about whether the changed URL shows up in your browser's address bar or not
  • Here's a simple example — redirecting gg.domain.com to domain.com/file.php?i=3&n=7:

RewriteEngine on 
RewriteRule ^(.*)$ http://www.domain.com/file.php?i=3&n=7 [R] 
    • Note the [R] -- don't know what that means (so far) and there are other letters used in a similar fashion.
      • "R is "redirect"

Without the R, the server attempts to display the "revised" content while maintaining the same URL that the user typed into the browser.

With the R, the browser will be able to see that the URL has been revised. I hope this makes sense!"
      • "[L] after a RewriteRule means "last rule", i.e. if this rule is applied, then don't apply any of the rules that follow."
  • You can activate rewrite rules from more than one place, including a .htaccess file and the apache configuration file (???) (/etc/httpd.conf?) unfortunately, you apparently cannot turn rewrite logging on / off in a .htaccess file

  • Here's a simple set of rules starting logging:
RewriteEngine on 
RewriteLog "/usr/local/apache/logs/myrewrite.log" 
RewriteLogLevel 9 

  • More examples


  • () RandyKramer - 07 Apr 2003
  • <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>

Page Ratings

Topic revision: r1 - 2003-04-07 - RandyKramer
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look