Redirect old domain with query paramaters

The old domain is: www.example.com/newspage.asp?m=4&y=2015 and I need that URL, as well as that URL with different query paramaters to go to: example.com/news. So, you are also changing the host with this redirect (www subdomain to bare domain)? Otherwise, it just looks like you can ignore the query string. This is relatively trivial to do … Read more

How do I apply friendly URL permalinks to a custom WordPress template?

Add the following code In your main hooks file (maybe in functions.php) add_action(‘init’, ‘my_custom_rewrite_rules’); Then add this function function my_custom_rewrite_rules() { // The rule // Input: archives/publications/countries/kenya // Output: archive-template.php?posttype=publications&taxo=countries&slug=kenya add_rewrite_rule(‘archives/publications/countries/([^/]+)/’, ‘archive-template.php?posttype=publications&taxo=countries&slug=$matches[1]’, ‘top’); // Flush the rules (to activate them) flush_rewrite_rules(); } To learn more about regex and rewrite rules, those links might help https://regexone.com/ … Read more

How to create a redirect in the .htaccess file, with 2 exceptions

Try the following, before the existing WordPress directives: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !^(abc|abc-def-g)$ / [R,L] This states that for any URL that is not /abc or /abc-def-g and which does not map to a physical file or directory (ie. your static resources, images, CSS, JS, etc.) then redirect to the homepage. The … Read more

.htaccess RewriteCond excluding directories does not work when there is an .htaccess or php.ini in subdirectory

You can try adding RewriteEngine On to the top of the subdirectory .htaccess file. This will have the effect of completely overriding the mod_rewrite directives in the parent (ie. WordPress) .htaccess file, because mod_rewrite directives are not inherited by default. So by enabling the rewrite engine in the subdirectory, the WordPress front-controller will not execute … Read more

where to add redirection rewriterule in .htaccess file?

Your external redirect needs to go at the very top of your .htaccess file, before the WordPress front-controller (ie. before the # BEGIN WordPress section). If you place it at the end of the file then it will simply never get processed, because the WordPress front-controller routes all URLs and then stops further processing. If … Read more