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
46
votes
6answers
67k 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: ...
27
votes
8answers
32k 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 ...
24
votes
4answers
48k 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')...
21
votes
6answers
16k 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 ...
19
votes
3answers
39k 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 "...
18
votes
3answers
51k 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/...
18
votes
7answers
26k 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 ...
17
votes
4answers
99k 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() ...
17
votes
3answers
19k 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 ...
17
votes
7answers
59k 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(){ ...
17
votes
3answers
12k views

Host the wp-admin on another domain?

Currenly I have a client that has a WordPress running on, let's say, www.example.com. I'm working on a new version using another technology/language that will be hosted on another server.. But the ...
16
votes
17answers
64k 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=...
16
votes
2answers
22k views

When I change slug, will WordPress create redirect from the old URL?

When I change a slug from post-a to post-b, will WordPress create a redirect from /post-a to /post-b, like HTTP 301 or something similar? If not, is there a plugin for that?
15
votes
4answers
19k 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 ...
14
votes
2answers
13k 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 ...
13
votes
6answers
37k views

“Too many redirects” ONLY when trying to access wp-admin page

I figured I would ask my own question seeing as the duplicate question(s) still haven't been answered. For some reason after my fresh install of Wordpress 4.9.1 on my Ubuntu VPS, enabling my "...
13
votes
2answers
30k views

Wp_redirect and sending variables

How to send some variables with wp_redirect() from function.php file in my theme folder? if ( $post_id ) { $variable_to_send = '1'; wp_redirect( home_url(), $variable_to_send ); exit; } ...
13
votes
7answers
32k 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 ...
11
votes
4answers
7k 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 ...
11
votes
3answers
3k views

How does WordPress handle permalinks?

WordPress auto corrects the permalinks(URLs) even if it is entered incorrectly. For e.g. WordPress will land you in example.com/some-post even if you enter example.com/idontexist/some-post or even ...
10
votes
9answers
69k views

WordPress Redirect All HTTP requests to HTTPS via .htaccess

I've done this many times before, and yet I'm not managing to do this again for some unknown reason. Tried endless solutions. Everything I've tried results in an endless redirect loop. What is the ...
10
votes
3answers
15k 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 ...
10
votes
2answers
14k 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 ...
10
votes
2answers
20k views

Wordpress redirecting connections on port 8080 to 80

I have a wordpress blog which is served by apache2(on port 80) and nginx(on port 8080) on Ubuntu 12.04. Now whenever a client connects via port 80 all is hunky dory, but when a client connects to 8080 ...
10
votes
4answers
5k 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 ...
9
votes
2answers
4k 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 ...
9
votes
1answer
344 views

How to prevent redirect to 'About' after core upgrade?

In wp-admin/includes/update-core.php we find the following line: add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); I want to remove this action, so I created a mu plugin ...
8
votes
1answer
7k 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 ...
8
votes
1answer
66k views

Redirect Localhost wordpress site to dashboard

I Upload Wordpress Website From Server to Localhost When I Open http://localhost/wordpress/wp-admin it redirect to me http://localhost/dashboard/
8
votes
2answers
4k views

Why is wp_redirect() preferable to a standard PHP header redirect?

In asking a question about hooks and redirects, I was advised to use wp_redirect in place of the PHP header function. Just wondering why wp_redirect is preferable?
8
votes
3answers
9k views

How do I programmatically generate a 404?

How can I get something like this to work? // in a plugin / theme: // This imaginary function will make WordPress think that the // current request is a 404. // Ideally this function could be ran ...
8
votes
1answer
12k views

Login redirect to previous page

I have a custom login page at http://netballscoop.com/log-in/ When you fill the username and password it redirects you to the previous page you were on perfectly. When you click Log Out it redirects ...
7
votes
7answers
87k 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'; ...
7
votes
4answers
36k 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('/...
7
votes
3answers
21k 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-...
7
votes
2answers
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 ...
7
votes
1answer
5k views

Custom post type yearly/ monthly archive permalinks

I have a custom post type "news" in my Wordpress site. I am using Advanced Custom Fields plugin to add meta data to each post. I want to create an array of news items as an archive: [2013] [...
7
votes
1answer
45k views

Check IF is a “single product page” and Check the “role” for a Redirect

After much research on the net, I have not found a solution that works. Do you know how can I do that on woocommerce : I try that for the moment : function cm_redirect_users_by_role() { $...
7
votes
3answers
10k views

User redirect to destination URL after login

Scenario: if user not login, user redirect to customize login page and redirect again to destination page after login. I don't use a function or plugin. This code to restriction page: if (!...
7
votes
2answers
4k views

Why is WordPress Multisite redirecting to wp-signup.php and how to fix it?

I have recently set up a second blog on my Wordpress multisite. The primary blog on the Multisite is www.example.com, and the second blog I have set up two days ago is www.example2.org. Unfortunately,...
6
votes
2answers
5k views

Prevent access to single post types

Say that I want to make a post type called 'press' and it is mostly concerned with linking a title with a PDF document of a press clipping. I want to show all of these as an archive... so something ...
6
votes
2answers
11k 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(...
6
votes
2answers
4k views

Redirection plugin - how to let the editor access the 'redirection' menu?

I'm using the Redirection plugin. It enables a 'Redirection' submenu under "Tools" menu in Admin panel. As an Administrator I can access the plugin. But I want to avail it for my 'editor' accounts too....
6
votes
1answer
8k 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.
6
votes
4answers
13k views

How to change the default logout link on WordPress Admin

I want to use another link for logout because I have /wp-admin/* protected with htpassword. Is there a way to do this? Something like creating a custom page like site.com/logout then use it as my new ...
6
votes
1answer
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 ...
6
votes
1answer
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 ...
6
votes
3answers
10k views

SSL redirect loop using Wordpress HTTPS Plugin

I'm using Wordpress in a NginX server proxying to an apache server which serves the pages. Recently we wanted to force the use of SSL at least in the Admin section, so we installed the Wordpress HTTPS ...
5
votes
1answer
6k views

add_rewrite_rule: $matches var not replaced by captured value

I want to access a plugin file (when <a> is clicked) without exposing actual path of the file. I am using the following rewrite rule: add_rewrite_rule( 'continue/([0-9]+)/?$', 'wp-content/...
5
votes
5answers
19k views

Removing the redirect after changing a page's slug

On one of my pages I changed the slug to form a different URL. E.g. Old: http://example.com/old-slug New: http://example.com/new-slug WordPress has done it's thing of redirecting http://example.com/...

1
2 3 4 5
35