Your SlideShare is downloading. ×
  • Like
mod_rewrite
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

mod_rewrite

  • 1,646 views
Published

A wonderful introduction to the world of mod_rewrite

A wonderful introduction to the world of mod_rewrite

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
1,646
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
86
Comments
1
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. mod_rewrite
  • 2. Uses
  • 3. Uses • Obscure original URLs
  • 4. Uses • Obscure original URLs • Clean URLs
  • 5. Uses • Obscure original URLs • Clean URLs • SEO (Seriously.)
  • 6. Uses • Obscure original URLs • Clean URLs • SEO (Seriously.) • Redirection
  • 7. Uses • Obscure original URLs • Clean URLs • SEO (Seriously.) • Redirection • Access control
  • 8. Where can I place rewrite rules?
  • 9. Where can I place rewrite rules? • httpd.conf (or included config files)
  • 10. Where can I place rewrite rules? • httpd.conf (or included config files) • VirtualHost
  • 11. Where can I place rewrite rules? • httpd.conf (or included config files) • VirtualHost • Directory*
  • 12. Where can I place rewrite rules? • httpd.conf (or included config files) • VirtualHost • Directory* • .htaccess
  • 13. Where can I place rewrite rules? • httpd.conf (or included config files) • VirtualHost • Directory* • .htaccess *Certain restrictions apply.**
  • 14. Where can I place rewrite rules? • httpd.conf (or included config files) • VirtualHost • Directory* • .htaccess *Certain restrictions apply.** **Use .htaccess files
  • 15. Directives
  • 16. Directives • RewriteEngine
  • 17. Directives • RewriteEngine • RewriteOptions
  • 18. Directives • RewriteEngine • RewriteOptions • RewriteRule
  • 19. Directives • RewriteEngine • RewriteOptions • RewriteRule • RewriteCond
  • 20. Directives • RewriteEngine • RewriteOptions • RewriteRule • RewriteCond • RewriteLog
  • 21. Directives • RewriteEngine • RewriteOptions • RewriteRule • RewriteCond • RewriteLog • RewriteBase
  • 22. Directives • RewriteEngine • RewriteOptions • RewriteRule • RewriteCond • RewriteLog • RewriteBase • ...and more! (that we won’t cover)
  • 23. Exhibit A # Default WordPress rewrite rules RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
  • 24. Exhibit A, Explained # Default WordPress rewrite rules # Turn rewrite engine on RewriteEngine On # Base all rewrites on ‘/’ URL RewriteBase / # If the requested file does not exist RewriteCond %{REQUEST_FILENAME} !-f # ...or if no directory exists... RewriteCond %{REQUEST_FILENAME} !-d # Rewrite the URL to /index.php RewriteRule . /index.php [L]
  • 25. RewriteEngine on | off
  • 26. RewriteEngine on | off • Enables or disables the runtime rewriting engine
  • 27. RewriteEngine on | off • Enables or disables the runtime rewriting engine • Required inside VirtualHost and .htaccess
  • 28. RewriteRule pattern substitution [flags] • Can occur more than once • Processed in order • First rule processed on URL path • Subsequent rules processed on previous output • Think of chaining commands together in bash
  • 29. RewriteRule pattern substitution [flags]
  • 30. RewriteRule pattern substitution [flags] • PCRE (Perl-Compatible Regular Expressions)
  • 31. RewriteRule pattern substitution [flags] • PCRE (Perl-Compatible Regular Expressions) • Matches the URL path
  • 32. RewriteRule pattern substitution [flags] • PCRE (Perl-Compatible Regular Expressions) • Matches the URL path • RewriteCond required to match anything else
  • 33. Regex (?:(?:rn)?[ t])*(?:(?:(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:
  • 34. [t])*(?:[^()<>@,;:" .[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|[([^ []r]|.)*](?:(?:rn)?[ t])*))*(?:,@(?:(?:rn)?[t])*(?:[^()<>@,;:". [] 000-031]+(?: (?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[ t])*)(?:.(?: (?:rn)?[t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))| [([^[]r]|.)*](?:(?:rn)?[ t])*))*)*:(?:(?:rn)?[t])*)?(?:[^()<>@,;:".[] 0 00- 031]+(?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|"(?:[^"r]| .|(?:(?:rn)?[t]))*"(?: (?:rn)?[ t])*)(?:.(?:(?:rn)?[ t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z| (?=[["()<>@,;:".[]]))|"(? :[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t])*))*@(?:(?:r n)?[ t])* (?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))| [([^[]r]|.)*](?:(?:rn)?[ t])*)(?:.(?:(?:rn)?[t])*(?:[ ^()<>@,;:".[] 000-031]+ (?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[ t])*))* >(?:(?:rn)?[t])*)(?:,s*( ?:(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(?=[ ["()<>@,;: ".[]]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t])*)(?:.(?:( ?:rn)? [t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|"(?:[^ "r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t ])*))*@(?:(?:rn)?[ t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)? Regex [t])*)(? :.(?:(?:rn)?[ t])*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[ ["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*))*|(?: [^()<>@,;:".[] 000-031]+ (?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[ ]]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:r n)?[ t])*)*<(?:(?:rn) ?[t])*(?:@(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(? =[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*)(?:.(?:(?:rn) ?[ t])*(?: [^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]| .)*](?:(?:rn)?[t])*))*(?:,@(?:(?:rn)?[ t])*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)? [ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*)(?:.(?:(?:rn)? [ t] )*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^ []r]|.)*](?:(?:rn)?[ t])*))*)*:(?:(?:rn)?[t])*)? (?:[^()<>@,;:".[] 000-031]+(?: (?:(?:rn)?[t])+|Z|(?=[["()<>@,;:". []]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)? [ t])*)(?:.(?:(?: rn)?[t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[ ["()<>@,;:".[]]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t]) *))*@(?:(?:rn)? [ t])*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^ []r]|.)*](?:(?:rn)?[t])*)(?: .(?:(?:rn)?[ t])*(?:[^()<>@,;:".[]000-031]+(?:(?: (?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*))*>(?:( ?: rn)?[ t])*))*)?;s*)
  • 35. [t])*(?:[^()<>@,;:" .[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|[([^ []r]|.)*](?:(?:rn)?[ t])*))*(?:,@(?:(?:rn)?[t])*(?:[^()<>@,;:". [] 000-031]+(?: (?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[ t])*)(?:.(?: (?:rn)?[t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))| [([^[]r]|.)*](?:(?:rn)?[ t])*))*)*:(?:(?:rn)?[t])*)?(?:[^()<>@,;:".[] 0 00- 031]+(?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|"(?:[^"r]| .|(?:(?:rn)?[t]))*"(?: (?:rn)?[ t])*)(?:.(?:(?:rn)?[ t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z| (?=[["()<>@,;:".[]]))|"(? :[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t])*))*@(?:(?:r n)?[ t])* (?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))| [([^[]r]|.)*](?:(?:rn)?[ t])*)(?:.(?:(?:rn)?[t])*(?:[ ^()<>@,;:".[] 000-031]+ (?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[ t])*))* >(?:(?:rn)?[t])*)(?:,s*( ?:(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(?=[ ["()<>@,;: ".[]]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t])*)(?:.(?:( ?:rn)? [t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|"(?:[^ "r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t ])*))*@(?:(?:rn)?[ t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)? Regex [t])*)(? :.(?:(?:rn)?[ t])*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[ ["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*))*|(?: [^()<>@,;:".[] 000-031]+ (?:(?:(?:rn)?[t])+|Z|(?=[["()<>@,;:".[ ]]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:r n)?[ t])*)*<(?:(?:rn) ?[t])*(?:@(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[t])+|Z|(? =[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*)(?:.(?:(?:rn) ?[ t])*(?: [^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]| .)*](?:(?:rn)?[t])*))*(?:,@(?:(?:rn)?[ t])*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)? [ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*)(?:.(?:(?:rn)? [ t] )*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^ []r]|.)*](?:(?:rn)?[ t])*))*)*:(?:(?:rn)?[t])*)? (?:[^()<>@,;:".[] 000-031]+(?: (?:(?:rn)?[t])+|Z|(?=[["()<>@,;:". []]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)? [ t])*)(?:.(?:(?: rn)?[t])*(?:[^()<>@,;:".[] 000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[ ["()<>@,;:".[]]))|"(?:[^"r]|.|(?:(?:rn)?[t]))*"(?:(?:rn)?[ t]) *))*@(?:(?:rn)? [ t])*(?:[^()<>@,;:".[]000-031]+(?:(?:(?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^ []r]|.)*](?:(?:rn)?[t])*)(?: .(?:(?:rn)?[ t])*(?:[^()<>@,;:".[]000-031]+(?:(?: (RFC 822 Compliant Email Validation) (?:rn)?[ t])+|Z|(?=[["()<>@,;:".[]]))|[([^[]r]|.)*](?:(?:rn)?[t])*))*>(?:( ?: rn)?[ t])*))*)?;s*)
  • 36. Regex ® It’s Not That Hard™
  • 37. RewriteRule pattern substitution [flags]
  • 38. RewriteRule pattern substitution [flags] Can be one of several things:
  • 39. RewriteRule pattern substitution [flags] Can be one of several things: • file-system path
  • 40. RewriteRule pattern substitution [flags] Can be one of several things: • file-system path • URL path
  • 41. RewriteRule pattern substitution [flags] Can be one of several things: • file-system path • URL path • Absolute URL
  • 42. RewriteRule pattern substitution [flags] Can be one of several things: • file-system path • URL path • Absolute URL • - [dash] (no substitution)
  • 43. RewriteRule pattern substitution [flags]
  • 44. RewriteRule pattern substitution [flags] • Affect behavior of the Rule or Condition
  • 45. RewriteRule pattern substitution [flags] • Affect behavior of the Rule or Condition • Contained in square brackets
  • 46. RewriteRule pattern substitution [flags] • Affect behavior of the Rule or Condition • Contained in square brackets • Comma-separated
  • 47. RewriteRule pattern substitution [flags] • Affect behavior of the Rule or Condition • Contained in square brackets [NC] • Comma-separated
  • 48. RewriteRule pattern substitution [flags] • Affect behavior of the Rule or Condition • Contained in square brackets [NC] • Comma-separated [NC, QSA, L]
  • 49. RewriteRule pattern substitution [flags]
  • 50. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 51. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 52. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 53. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 54. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 55. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 56. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 57. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 58. RewriteRule pattern substitution [flags] C Chain this rule to the next rule E Set environment variable F 403 Forbidden Status G 410 Gone Status H Specify handler L Don’t process rules after this one NC Case-insensitive QSA Append query string R[=301] Redirect (R=HTTP Status Code)
  • 59. RewriteCond variable pattern [flags] • HTTP Server Variables (HTTP_HOST, REQUEST_URI) • Pattern that must match the given variable • Optional flags that change the behavior, just like RewriteRule
  • 60. RewriteCond variable pattern [flags]
  • 61. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 62. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 63. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 64. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 65. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 66. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 67. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 68. RewriteCond variable pattern [flags] HTTP_REFERER HTTP_HOST REMOTE_ADDR REQUEST_METHOD SERVER_PORT HTTP_USER_AGENT REQUEST_URI etc.
  • 69. Exhibit A, Explained (Again) # Default WordPress rewrite rules # Turn rewrite engine on RewriteEngine On # Base all rewrites on ‘/’ URL RewriteBase / # If the requested file does not exist RewriteCond %{REQUEST_FILENAME} !-f # ...or if no directory exists... RewriteCond %{REQUEST_FILENAME} !-d # Rewrite the URL to /index.php RewriteRule . /index.php [L]
  • 70. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Pattern Flags Substitution
  • 71. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Match this pattern Pattern inside parentheses is capture as variable ‘$1’
  • 72. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Substitute it with “http://www.example.com”
  • 73. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] The pattern captured inside the parentheses
  • 74. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  • 75. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Redirect with a 301 Code
  • 76. non-www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Make this the last RewriteRule
  • 77. RewriteOptions inherit
  • 78. RewriteOptions inherit • Inherit the configuration of the parent
  • 79. RewriteOptions inherit • Inherit the configuration of the parent • In per-virtual-server context, maps, conditions and rules of the main server are inherited
  • 80. RewriteOptions inherit • Inherit the configuration of the parent • In per-virtual-server context, maps, conditions and rules of the main server are inherited • In per-directory context, conditions and rules of the parent directory's .htaccess configuration are inherited
  • 81. Example
  • 82. Example in httpd.conf
  • 83. Example in httpd.conf ... RewriteRule ^(.*)$ index.php ... <VirtualHost 192.168.1.120:80> ServerName zomgbacon.com DocumentRoot /home/bacon/public_html # Turn on the rewrite engine and inherit any rules RewriteEngine On RewriteOptions Inherit </VirtualHost> ...
  • 84. RewriteBase URL-path
  • 85. RewriteBase URL-path • Sets the base URL for per-directory rewrites
  • 86. RewriteBase URL-path • Sets the base URL for per-directory rewrites • URLs are NOT directly related to physical filename paths
  • 87. RewriteBase Example
  • 88. RewriteBase Example in .htaccess file
  • 89. RewriteBase Example in .htaccess file # # /abc/def/.htaccess -- per-dir config file for directory /abc/def # Remember: /abc/def is the physical path of /xyz, i.e., the server # has a 'Alias /xyz /abc/def' directive e.g. # RewriteEngine On # let the server know that we were reached via /xyz and not # via the physical path prefix /abc/def RewriteBase /xyz # now the rewriting rules RewriteRule ^oldstuff.html$ newstuff.html
  • 90. RewriteLog log-path
  • 91. RewriteLog log-path • Logs rewrites
  • 92. RewriteLog log-path • Logs rewrites • Level of logging can be tuned
  • 93. RewriteLog log-path • Logs rewrites • Level of logging can be tuned • Relative paths are relative to DocumentRoot
  • 94. RewriteLog log-path • Logs rewrites • Level of logging can be tuned • Relative paths are relative to DocumentRoot • Absolute paths are...well, absolute.
  • 95. RewriteLogLevel level
  • 96. RewriteLogLevel level • Integer value 0-9
  • 97. RewriteLogLevel level • Integer value 0-9 • 0 == disabled
  • 98. RewriteLogLevel level • Integer value 0-9 • 0 == disabled • 9 == log nearly everything
  • 99. RewriteLogLevel level • Integer value 0-9 • 0 == disabled • 9 == log nearly everything • More verbose, greater impact on performance
  • 100. RewriteLogLevel level • Integer value 0-9 • 0 == disabled • 9 == log nearly everything • More verbose, greater impact on performance • Higher levels == 2 or higher for debugging only
  • 101. Logging Examples
  • 102. Logging Examples in httpd.conf
  • 103. Logging Examples in httpd.conf ... <VirtualHost 192.168.1.120:80> ServerName zomgbacon.com DocumentRoot /home/bacon/public_html # /home/bacon/public_html/rewrite.log RewriteLog rewrite.log # Make it semi-verbose RewriteLogLevel 5 # turn on rewrite engine and inherit rules RewriteEngine on RewriteOptions Inherit </VirtualHost> ...
  • 104. fin