Questions tagged [redirect]

"HTTP Redirection" – the process by which a request for one URL is automatically replaced by a request for a different, usually related, URL.

Filter by
Sorted by
Tagged with
15 votes
3 answers
17k views

Redirect function inside a Shortcode

I am developing a free plugin for connection a external support system to WordPress to be able to authenticate users on WordPress. For this, currently from the external system, the user is sent to ...
24 votes
5 answers
127k views

How to redirect non-logged in users to a specific page?

How to redirect non-logged users requesting for a specific page/URL to another page/URL and display a message like "for members only". I know its quite easy to code using !is_user_logged_in() ...
5 votes
3 answers
7k views

Creating 301 Redirects for Post, Page, Category and Image URLs?

I fear this may be too much to ask here, so if so, please feel free to tell me of another place to learn. Help with Redirections I'm cleaning up a badly developed site and migrating wordpress from a ...
's user avatar
51 votes
7 answers
80k views

How to force a 404 on WordPress

I need to force a 404 on some posts based on conditions. I managed to do it ( although I don't know if I did it the right way) and I'm a getting my 404.php template to load as expected. My code: ...
  • 5,505
28 votes
4 answers
63k views

Redirect Restricted Page to 404

Is there a way to show a 404 page if the current logged in user does not have the right clearance to view the page? I am looking for a PHP method, something like if( !current_user_can('administrator')...
  • 3,322
10 votes
2 answers
5k views

Disable ONLY URL auto complete, not the whole canonical URL system

I have a blog with several pages in some category "projects" that are structured/named like this: /projects/project-2012 /projects/project-2013 /projects/project-2014 /projects/project-2015 When a ...
  • 351
10 votes
4 answers
6k views

How to show a single post on the front page but have normal paging?

I would like to have a single post on my front page (always the latest), but let normal paging work. So the front page has post 1, the next page should have post 2-11 (1-10 is fine too), then 12-21 or ...
  • 30.1k
7 votes
2 answers
4k views

Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/

I made a site some time ago and after some days some posts were indexed by search engines. Today I changed the permalink structure from /%postname%/ to /%category%/%postname%/. After that, when ...
17 votes
7 answers
64k views

Redirect user to original url after login?

I have a function that redirects users to the login page (home) if they're trying to access any other page without being logged in, here's how it works: function restrict_access_if_logged_out(){ ...
7 votes
2 answers
12k views

Making a plugin file accessible via url rewrite?

In my WordPress plugin I have a php file that generates some stats about the blog and outputs it as a simple text file. To access WordPress functions I've included this at the top of the file: define(...
's user avatar
6 votes
1 answer
4k views

Changing attachment urls?

How can I change the format of attachment page urls from /[post-url]/[attachment-name]/ to /media/[attachment-name]/? I understand that I can override the output of get_attachment_link via the ...
  • 30.1k
18 votes
4 answers
24k views

Disable Wordpress URL auto complete

I recently noticed that Wordpress tries to auto-complete a URL when it's not submitted in its entirety. E.g. I have a post URL that looks like this: http://www.mysite.com/some-post-title If I browse ...
  • 551
8 votes
1 answer
8k views

301 redirect instead of 404 when URL is a prefix of a post or page name?

hey all! i have an odd problem with URL routing. when i request a URL that doesn't exist, e.g. http://localhost/foo, wordpress correctly returns a 404. however, if that URL is a prefix of a post or ...
  • 273
5 votes
4 answers
51k views

How to redirect a sucessful registration to a page template?

Each time I register I end up in the wp-login page (back-end): Is there any way of redirecting the users who register to a page template (front-end)?
  • 3,717
11 votes
3 answers
19k views

Redirect entire website to a single page

I need to redirect a whole WordPress site to a single WordPress page. A sort of maintenance mode, but the redirect has to go to a published WordPress page. Unfortunately, the maintenance page I need ...
's user avatar
3 votes
4 answers
11k views

How to redirect all requests to wp-login.php?

I created some custom login/registration template pages and now I want that every request to wp-login.php to be redirected to a custom url. Now I have something like this: add_action('init','...
6 votes
1 answer
7k views

Stop Wordpress from "guessing" redirects for nonexistent URLs

Wordpress sometimes "guesses" a redirection for a nonexistent page slug if the slug is at the beginning of another URL. After some searching, my hypothesis is that this part of the canonical ...
  • 2,918
11 votes
3 answers
16k views

My wordpress multisite homepage redirects to signup page

So I just setup my website fightify.com and as you will see, visitors are automatically redirected to a signup page, which shouldnt be happening. This only occurs if the domain is typed without the ...
's user avatar
0 votes
1 answer
1k views

Can Not Redirect from Plugin-Registered Admin Page

I am doing the following in my plugin: Register a custom admin page and in the callback function (the last parameter of add_submenu_page) Redirect to another page However, when I open the custom ...
  • 152
0 votes
1 answer
2k views

How to redirect search result page to post

I'd like to redirect a search result page URL to a specific post. I've tried doing a 301 redirect in the .htaccess but it is not working. As an example: I want to redirect permanently the URL http:...
19 votes
7 answers
30k views

How do I skip wordpress's 404 handling and redirect all 404 errors for static files to 404.html?

How do I skip wordpress's 404 handling and redirect all 404 errors for static files to 404.html? I read and it seems its not possible when using permalinks? The objective is to reduce the server ...
21 votes
3 answers
57k views

How to prevent automatic redirection of 404 errors and "incorrect" URLs?

Wordpress has a feature whereby it will automatically redirect your URLs if it percieves them to be written wrongly. Here is an example: I have a page called my-page If I go to: www.mysite.com/...
  • 976
7 votes
4 answers
47k views

Redirect to referring page after logging in

I am not using any custom login plugins or any bespoke code. A few of my pages have got this bit of code in them at the very beginning. <?php if(!is_user_logged_in()) wp_redirect('/...
5 votes
2 answers
15k views

How to disable Multisite sign-up page?

If we try to access a non-existant Multisite site, e.g., http://site1.example.com or http://example.com/site1/, we are redirected to http://example.com/wp-signup.php?new=site1. How to block this and ...
  • 21.8k
4 votes
1 answer
3k views

Passing variables through permalink structure

I have a WordPress page which is accessible via /accommodation/. What I want to be able to do is pass in a parameter using the URL - ie going to /accommodation/value1/ would load the same page as /...
3 votes
2 answers
6k views

Redirect to custom url when registration fails?

When I want to redirect the user after successful registration, I just use "registration_redirect" filter hook. How about when registration fails, which filter hook should I use? I looked into wp-...
  • 317
16 votes
7 answers
43k views

WordPress localhost site redirect to live site

I have download the code and export the database from server and setup the site on my localhost also I have been changed the home and site URL in wp_options table I am able to login at wp-admin but ...
7 votes
4 answers
29k views

Best Way to Redirect Category to Page and Hide Category

I have a category archive page at: http://mysite.com/news It displays an archive of items from the category 'news-article' I'd like to redirect any requests for http://mysite.com/category/news-...
4 votes
2 answers
34k views

Login to wp-admin "redirect_to" points to wrong URL after migration

I have a WordPress site hosted on GoDaddy, it's a Windows server, (i have the web.config set up). and .htaccess correctly configured. The site was working on example.com/wordpress , as it was a ...
1 vote
2 answers
509 views

How do I skip wordpress's 404 handling?

I want to extend my website in a way that is parallel to the wordpress theme. Example: My website with wordpress is at: www.mywebsite.com By ftp I added a directory named test, in which there is a ...
0 votes
3 answers
18k views

How to: 301 Redirect /category/ to /customname/

I've changed our "category base" in WP settings from the default "category" to "customname". Now there are 404 errors to links containing the old category slug eg. mysite.com/category/names What do ...
  • 137
21 votes
3 answers
50k views

Admin Page Redirect

Is it possible to redirect users to an admin page if they access another admin page? For example if they a user ever hits "all pages" /wp-admin/edit.php?post_type=page they would get redirected to "...
  • 711
2 votes
3 answers
2k views

flush_rewrite_rules not working on plugin deactivation, invalid URLs not showing 404

i'm just about to release a community plug-in and have a few last anoying issues. First, whenever i visit a page that would not be valid for the plugin, www.mydomain.com/forms/tester it will take me ...
  • 149
1 vote
1 answer
440 views

Redirect all users, except network administrators, from the main site to a subsite

I have a WP Multisite / Multi Network installation. What I need is to redirect all non-logged and also all logged in users, except logged in network administrators, from the main site example.com (...
  • 1,101
1 vote
6 answers
491 views

Pages 404 in wordpress

First of all, I am very new to wordpress and know almost nothing about it. When I create the page foo using in wp-admin, I get the message that the page is created. When I click on view page, it 404s....
  • 307
1 vote
1 answer
8k views

How to redirect users to custom lostpassword page?

How to redirect users to custom lostpassword page when they click on the Error: Lost your password?. Because I set a redirect for wp-login.php to my custom login page. when a user click on Error: Lost ...
1 vote
3 answers
1k views

How to create a php url redirection for nicer links

I'm looking for a way to make a URL redirection for affiliate links on my website. Something like : site.com/go/keyword I know there is many plugins for doiing this, but i don't like plugin, and i ...
  • 544
0 votes
2 answers
4k views

How to? Redirect /category/sci-fi/ to /category/scifi/?

I changed the wordpress category slug from "sci-fi" to "scifi" a few months back by accident. How can I redirect /category/sci-fi/ to /category/scifi/ so that /category/sci-fi/page/2/, /category/...
  • 137
0 votes
2 answers
2k views

Changing pemalink structure to /%post_id%/%postname%/

I'm currently using permalink structure: /%year%/%monthnum%/%day%/%postname%/ I want to change that to: /%post_id%/%postname%/ I expect it to be: faster (database is sorted by post_id?) shorter ...
0 votes
1 answer
2k views

Error 310 too many redirects after switching domains

I'm at a loss here. My site is http://www.kgstiles.com and about 70% of my pages now result in a 310 error. There doesn't seem to be any pattern to the error, but one thing I thought was interesting: ...
0 votes
1 answer
2k views

Wordpress overriding actual subdirectories

I have a site driven by Wordpress and a few custom directories that I've got at the top level. Some of these top-level directories work and the content inside of them are being read as expected. ...
31 votes
8 answers
42k views

Resolve a custom post type name vs. page permalink conflict (same slug)

I have a custom post type called "visningshus", and also a Page with that slug. This is as it should (must) be. Currently, "http://my-site.com/visningshus" lists all posts of that type. I want to ...
29 votes
8 answers
22k views

Disable front end to use as CMS only?

I'm using the WordPress database and back end to administer the news for my band's website and everything is working great however I'd like to disable the front end of WordPress itself. I have the ...
11 votes
4 answers
8k views

Redirect Main Site to Subsite in Multisite Wordpress

I have multi-site wordpress, I want to redirect the main site to one of the sub-site but redirection in .htacecss gives error. Is there any way to redirect a main site to its sub-site. That looks not ...
  • 163
6 votes
1 answer
9k views

check first time login only

i want to display welcome message or redirect the user to my custom template when the user login for the first time only. After the user can visit the regular page of the site.
  • 563
20 votes
3 answers
27k views

Which hook should be used to add an action containing a redirect?

I want to build a plugin that grabs certain url params from the query string to build a new query string for the same page. I'm following the excellent the Professional WordPress Plugin Development ...
  • 1,765
12 votes
8 answers
109k views

wp_redirect() function is not working

wp_redirect($post->guid) is not working. How can I fix this? This is my code: if(isset($_REQUEST['vid']) ){ $id=$_REQUEST['vid']; $post_title = 'sasa'; $post_content ='zxczxczxc'; ...
4 votes
2 answers
8k views

prevent/block direct access to a thank you page

how to prevent/block direct access to a thank you page, only access if redirected from submiiting a form (in a different page)?
2 votes
2 answers
6k views

How do I redirect upon login a specific user based on role?

I'd like to force a user to a specific page upon login based on their role using if ( current_user_can('contributor') ) and the main login function function wp_loginout($redirect = '', $echo = true)...
19 votes
19 answers
89k views

Unable to login and wp-login.php redirects to wp-admin%2F&reauth=1?

I am having some difficulty logging into my WordPress site. When I attempt to visit example.com/wp-admin, I see a blank page and the url bar changes to: http://example.com/wp-login.php?redirect_to=...
  • 201