Best way to handle redirects
This plugin does the job very well.
This plugin does the job very well.
The best way of doing that is actually by just copying the post to your new blog, and on your old blog, add a rel=”canonical” link to that page to your new post’s URL. This will notify Google and other SE’s that you want to have the other, new, page ranking, without actually having to … Read more
Set the query string to p={post_id}. WordPress will redirect it to the proper URI then automatically.
Above the WordPress rewrite rules add: RedirectMatch permanent ^/([^/]+)\.html$ /$1 That will catch example.com/foo.html but not example.com/travel-guides/foo.html. To catch all URLs ending with .html remove the first ^ from the pattern. To redirect all URLs ending with .html except those in travel-guides you need mod_rewrite: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/travel-guides/ RewriteRule ([^/]+)\.html$ /$1 … Read more
The problem is that this function is normally used in the backend. To use it in the frontend, you need to add the following filter: add_filter( ‘auth_redirect_scheme’, ‘wpse16975_check_loggedin’ ); function wpse16975_check_loggedin(){ return ‘logged_in’; } Then auth_redirect() will work as expected : redirect users to the login form if they are not logged in.
This really belongs on ServerFault, StackOverflow or Webmasters… But basically, you need to add something along these lines before the WP rules begin: RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
From doing some research, I’d recommend trying out this plugin: Redirection. This plugin allows you to manage 301 redirections. I played around with the settings and they allows regular expressions which could do the following: http://some.site/hashtag?tag=some-tag/ to http://some.site/tags/some-tag/ They provide documentation on how to set it up which can be found here. This is what … Read more
The action wp_login_failed fires when there’s a failed login due to a faulty username/password combination. So that’s a good place to start. This is a super simple example that just redirects to the home page. <?php add_action( ‘wp_login_failed’, ‘wpse25628_login_failed’, 10, 1 ); /** * Catches all failed logins and redirect them to the * websites … Read more
One small hiccup is that you’ll need to update RewriteRule ./ in that second to last line. Here is an updated (and tested) snippet for you: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_URI} !^/foo/.*$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ./ /index.php [L] </IfModule> # END … Read more
You could also do this, function mod_redirect_subscriber_delete($user_id) { $user = get_user_by(‘id’, $user_id); $role = $user->roles[0]; if ($role == ‘subscriber’) { add_action(“deleted_user”, function(){ wp_redirect( admin_url(‘/index.php’) ); exit; }); } } add_action(“delete_user”, “mod_redirect_subscriber_delete”); Anonymous functions (closures), available in PHP 5.3+. Benefits: No need to remove the initial hook on delete_user No need to re-run wp_delete_user() You still … Read more