- [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,…

Resume Transcript Auto-Scroll

Author

Released

5/23/2016

Clean URLs are great. They're elegant, easier to remember, and more user friendly than dynamic URLs. But the primary reason to use clean URLs is for SEO: to make it easier for search engines to index your site. This translates to better search results and increased page visits. Find out how to reap the benefits of clean URLs in your PHP code, in this course with PHP expert David Powers.

Rather 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.