Join David Powers for an in-depth discussion in this video Creating simple regular expressions, part of Clean PHP URLs on Apache Server.
- [Voiceover] Some knowledge of regular expressions…is essential for using mod_rewrite.…If you're comfortable with regular expressions,…you can skip this video.…Otherwise, keep watching.…Let's start with a brief explanation…of what regular expressions are.…They're used to match text patterns.…In some respects, they're similar to wildcard characters,…but they're much more powerful.…One of the most powerful features is the ability…to use capturing groups to store matched text for reuse.…This allows you to create highly adaptable rewrite rules.…
Let's take a look at the basic rules…of creating a regular expression, or regex, for short.…Literal text matches itself,…but you can separate alternatives with a vertical pipe.…For example, this matches either arrangements or flowers.…The caret and dollar sign are anchors…for the beginning and end of the pattern.…A caret at the beginning means the matching text…must begin with the same pattern.…While a dollar sign at the end…means the matching text must end with it.…
Putting the caret at the beginning…
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.
- 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