URL Mapping - ApacheCon 2005
mod_rewrite examples (1)- Problem: Ugly URLs.
http://www.server.com/cgi-bin/program.cgi?A=arg1&B=arg2
| | |
- Want to have prettier ones.
http://www.server.com/program/arg1/arg2
| | |
- Solution: mod_rewrite
RewriteEngineOn
RewriteRule ^/program/([^/]+)/([^/]+) \
/cgi-bin/program.cgi?A=$1&B=$2 [PT]
| | |
- [^/]+ means "one or more character that is not a slash"
- ( ) traps the results in a variable
- [PT] Means "passthrough" which lets it still be treated as a URL, not a file path
|
|