Join David Powers for an in-depth discussion in this video Linking to a specific part of a page, part of PHP: Clean URLs on Apache Server.
- [Voiceover] In the example site, select Care for Orchids…in the main navigation menu.…The rewrite rule was created in the previous chapter,…loads the page with a clean URL,…rewrite/handp/care/orchids.…At the top of the page are six links…to specific parts of the current page.…If you click one of them,…it jumps to the selected section.…And the URL in the browser address bar…now has a hash and a section ID appended to it.…This is known as an HTML fragment identifier…and it's the normal way to link to…a specific part of a page.…
But let's take a look at that rewrite rule…that was created in the previous chapter.…Go to the editing program, and here it is…in .htaccess online 7.…And the incoming pattern ends with…orchids, followed immediately by a dollar sign.…That means the pattern should reject any URL…that contains anything appended after orchids.…So why is the rewrite rule still working…when we linked to a specific section in the page?…It's because webservers ignore the HTML…fragment identifier at the end of the URL.…
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