Which url points to which file

WordPress has a template hierarchy, he search down the files in your theme until he finds a suitable template for the content hes outputing following the hierarchy. Here it’s a example from de Codex: If your blog is at http://example.com/blog/ and a visitor clicks on a link to a category page such as http://example.com/blog/category/your-cat/, WordPress … Read more

Rewrite URL to get rid of wp-content etc and change URL

$matches[1] doesn’t work for external redirects, only internal (URL must start with index.php and handled by WordPress itself) Try this add_action(‘init’, ‘custom_rewrite_pdfURL’); function custom_rewrite_pdfURL() { add_rewrite_rule(‘^carPDF/([^/]*)/?’, ‘wp-content/themes/exampletheme/templates/pdf-generator.php?productID=$1’, ‘top’); } Don’t forget to flush permalinks

Rewrite rule not redirecting correctly

The answer is to not use plugins, just use Apache’s built in HTAccess. The trick with HTAccess and WordPress so as not to break wordpress rewrite features, is to place the new rule before the RewriteCond statement of wordpress. So the final looks like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule … Read more

url redirect none www to www

IMO, going to your .htaccess file is not necessary. You can instead flush permalink rules in the Permalink Settings area of your site. Just click on Permalinks, select a new option (other than the current one you’re using), save… Click on Permalinks again, choose your previous option, and then save again. And that does it!.

URL Rewrite and Archive Template Files – Post Type vs. Taxonomy

I handled this with a pre_get_posts hook (thanks, @Milo), passing in the URL part that corresponds to the slug I need. Hope this helps someone down the road. Improvements are welcome. Thanks. function filter_team_news_archives_by_sport_taxonomy($query) { if (is_post_type_archive(‘team-news’) && $query->is_main_query()){ // Get $sport_slug from URL — https://stackoverflow.com/a/36002190/4107296 $url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”; … Read more

Broken page redirect

I found solution – I needed to run flush_rules() method at least once to clean cache. //Ensure the $wp_rewrite global is loaded global $wp_rewrite; //Call flush_rules() as a method of the $wp_rewrite object $wp_rewrite->flush_rules( false );