Cannot get 301 redirection in htaccess to work (either Redirect or Rewrite)

The ^ in your rewriterule means the URL must begin with the postname, as in your new structure – so what you’re saying in that second line is, “redirect http://www.example.com/postname to http://www.example.com/postname“. So it’s the ^ that’s throwing things off. If you were previously using URLs like http://www.example.com/categoryname/postname/ then I would suggest instead: RewriteEngine On … Read more

How to add subdomain to htaccess

In your plugin: <?php register_activation_hook(WP_PLUGIN_DIR.’/your/plugin/path/plugin.php’, ‘wpse_set_subdomain’); function wpse_set_subdomain() { $siteurl = site_url(); $subdomain = substr($siteurl, 8, 3); // may need to adjust which substring to grab update_option(‘wpse_subdomain’, $subdomain); } ?> Then wherever you have conditional content: <?php $subdomain = get_option(‘wpse_subdomain’); if($subdomain == ‘www’) { // www code } else { // other code } ?> … Read more