- [Voiceover] One of the most powerful aspects…of mod_rewrite is the ability to set conditions…for rewriting URLs.…It's also, probably, the most complex.…You define a condition with the RewriteCond directive.…It's case-insensitive, but there must be no space…within the keyword.…It's followed by a space and the incoming value…that you want to match.…This can be literal text,…a server variable,…or a combination of both.…The condition comes after another space.…
We'll look at conditions in a moment.…You can apply mulitple conditions…to the same rewrite rule…by adding subsequent RewriteCond directives…on separate lines.…The conditions only apply to the next rewrite rule.…In this case, both conditions need to be true…for the rule to be applied.…To combine two conditions as alternatives,…add OR in square brackets after the first one.…In this example, the rewrite rule would be applied…if either condition is true.…
Server variables can be used in the incoming value…either on their own or combined with literal text.…They take this format,…
Released
5/23/2016Rather than checking URLs individually, David shows how to evaluate and update them sitewide with the Apache mod_rewrite module. Watch these tutorials to learn how to enable mod_rewrite on your server, understand the structure of mod_rewrite rules, remove unnecessary file extensions, convert query strings into readable numbers and text, and use rewrite maps to look up complex values without regular expressions. Plus, learn how to enhance search results and provide searchers with links to specific parts of a webpage.
- Checking your Apache setup
- Creating simple regular expressions
- Removing .php from URLs
- Replacing query strings
- Displaying clean URLs in search results
- Linking to parts of a webpage
- Creating a clean URL for any PHP file
Share this video
Embed this video
Video: Setting conditions for rewriting URLs