Questions tagged [redirection]

Redirection in Drupal means sending the users to a different page.

Filter by
Sorted by
Tagged with
22
votes
14answers
12k views

How do I hide the default page /node?

Drupal out of the box comes with a page (which is the default homepage) that is assigned to the node path. How do I avoid users reach it, and redirect them to the actual homepage of the site?
20
votes
1answer
10k views

What API function do I use for redirecting to external URLs?

When writing a module, for redirecting to Drupal paths, one uses drupal_goto. Is there some API function that I should use for redirecting to external pages? Or is setting the Location with ...
19
votes
3answers
18k views

Form Redirect not working if 'destination' is in URL

In one of my forms, I'm trying to set a $form_state['redirect'] so the form will go to that destination after the user clicks one of the action buttons. If I inspect $form_state['redirect'] both ...
16
votes
0answers
11k views

How do I perform a redirect to a custom URL after login? [duplicate]

I am trying to redirect users to a custom URL after they logged in, but my code doesn't work. How do I redirect users after they logged in?
15
votes
3answers
26k views

Redirect after form submission

I create custom Form in Drupal 8 ,I remember we can redirect to custom path in Drupal 7 with set $form_state['redirect'] = 'mycustompath'; in custom submit handler, but how can redirect User after ...
15
votes
4answers
16k views

Redirect to a custom page after a node has been added or edited

Using hook_form_alter, how can I redirect a user to a a custom page after creating or editing a node instead of the node that was created or edited? The current code for hook_form_alter() is the ...
14
votes
3answers
23k views

How to create a redirection programmatically? [closed]

I try to create a redirection 301 with the redirect module. For example, I want to redirect an URL source to an internal URL through my custom module. I want to create a redirection when I create a ...
14
votes
3answers
7k views

Redirect Anonymous user to login page

I want if user not logged in and visit any page of my website except my REST VIEWS routers I redirect him/her to login page in drupal 8, I found this solutions for drupal 7 but didn't find any ...
13
votes
17answers
19k views

Redirect after user login

I would like to redirect users after they log in. Is it possible to use hook_user_login() to make the redirection? How do I add the parameter for the redirection?
13
votes
6answers
10k views

How to redirect an anonymous user to the login form after a 403 error?

I want to redirect an anonymous user to the login form if such user encounters a 403 error. I have created event subscriber and this is my code, but I end up on loop on the current page. /** * ...
13
votes
6answers
15k views

Redirect user after node add/edit

I want to redirect users to a custom page, after they create a node or edit it.
12
votes
4answers
4k views

How include hash (#) in drupal_goto path?

Is there any way to include a # in drupal_goto? i want something like this function MYMODULE_preprocess_node(&$variables) { $node = $variables['node']; switch ($node->type) { case '...
11
votes
8answers
15k views

Path alias creates redirect loop or redirects to the front page

When I call our sit "www.example.com/contact-us" I'm getting the following error: Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a ...
10
votes
5answers
8k views

How to perform a redirect to custom page after node save or delete?

What I'm trying to do doesn't work, I still get redirected to /node/{id}: function hook_form_alter(&$form, $form_state, $form_id) { $form['actions']['submit']['#submit'][] = '...
9
votes
6answers
21k views

What function/method can I use to redirect users to a different page?

In Drupal 7, I use the following code. function my_goto($path) { drupal_goto($path, array(), 301); } What code should I use in Drupal 8?
8
votes
2answers
9k views

Redirect to the front page with a different language

i have a question about redirecting to a page with a different language. I found this old post for drupal 7 but I doesn't really help me - https://www.drupal.org/node/1280468 Now we are in Drupal 8 ...
8
votes
3answers
10k views

301 Redirect Module [closed]

I need to redirect specific broken/dead links to other pages within my site. I'm looking for a module that I can setup, then have my support team change without needed htaccess, etc. I came across ...
8
votes
2answers
799 views

How to avoid Drupal redirecting my multilingual Views pages?

I've got a Views page in a multilingual website where I need a different url for each language, ie: es: mysite/apartamentos. en: mysite/appartments. fr: mysite/appartements. ru: mysite/arendu. I ...
8
votes
2answers
2k views

Would redirecting users in hook_menu's access callback have any undesirable effects?

This answer led to a discussion about the best way to redirect a user to a specific page if they shouldn't have access to the page they are trying to access. One option is to set the access callback ...
7
votes
2answers
3k views

Force redirect in submit handler even though destination parameter set

I add a custom submit handler and now I want Redirect to custom route after form submitted. This is what I used use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\Request;...
7
votes
4answers
12k views

Is it possible to redirect after “pushing” a file to the user?

I've got a setup where a site generates internal analytics about site usage. Users are able to request a download of their personal analytics, and because this information is sensitive I do not create ...
6
votes
2answers
4k views

Making drupal_goto Ignore ?destination=foo

I frequently come across cases in my Drupal 6 sites where a user might encounter my module's pages with the ?destination=foo querystring appended to the URL, from previous interactions on the site. ...
6
votes
8answers
11k views

How to redirect toward a specific node from front-page in Drupal 7?

I have a multi language site made in Drupal 7. And I want to check if I am on the front page then if true to redirect the user to a to some specific node. I have tried different methods: to create ...
6
votes
2answers
4k views

How to use the Rules module to implement a custom redirect for an outdated URL?

I used to show content from a catalog via the Views module, accessing an external database, so that all of the URLs would be something like /content?name=[name]. For various reasons, I've opted to ...
6
votes
1answer
13k views

How to create a redirection in Drupal 8? [closed]

How to create a redirection in Drupal 8 ? By example, with hook, and after login or if an url is called.
6
votes
2answers
3k views

$form['redirect'] = “something=$someId”; doesn't work in Drupal 7

I am here again with a problem! I want to make a form redirect usign a url with ids and somethings else as parameter, but when the code is executed something encode my url, so, if I put something like ...
6
votes
1answer
5k views

form_state->setRedirect(to_a_new_node_page) from the submitForm function, route “does not exist” issue

I created a custom module, It generate a custom Form in a page. When I submit my form, I create a new node. So, I am redirect to the form page but I would like be redirect to the new node page. I add ...
6
votes
1answer
2k views

How to redirect to external URL upon form submission

I've extended a FormBase and I've defined the submitForm method. In this method I want to redirect to an external URL (https://example.com/my/path?amount=33&gift=0&product_id=1) $myurl = "...
6
votes
2answers
2k views

TrustedResponseRedirect failing - how to prevent cache metadata?

I am getting the following when trying to redirect to an external site from my controller function defined in my routing file: return new TrustedRedirectResponse($my_ext_url); LogicException: The ...
6
votes
2answers
3k views

Is there a way to create a taxonomy path redirect?

I am trying to create a taxonomy redirect for specific taxonomy URL. Basically what Taxonomy Redirect did for Drupal 6 but for Drupal 7. I have searched the Drupal 7 API for hook_term_path but don't ...
6
votes
3answers
2k views

How to prevent a node being saved when using the Rules module?

Is it possible to prevent a node from being saved with Rules? This is what I do now: Create a rule Before saving content of type ''. Condition: IF ... TRUE => Redirect & set message Create a ...
5
votes
4answers
755 views

Redirect on Login?

I have tried making this a rule as well as used hook_user with no luck. It definitely gets inside of the login case (had a watchdog log), but the redirect doesn't happen and they are still sent to /...
5
votes
5answers
3k views

How can I redirect users upon login sometimes but not break the “Forgot password?” function?

I'm using Rules to redirect users with certain roles upon login using the Page Redirect action. The "Force redirect" option is set to true (changing this to false does not fix the problem, and if it ...
5
votes
3answers
3k views

How can I turn off caching redirect?

I have a url that would normally redirect to a specific page, however, some code is run prior to this. I am returning a RedirectResponse instance, and it appears to be being cached. How can I force ...
5
votes
3answers
978 views

How to restrict access to a node via node/12 and allow access via a path like content/sometitle?

Problem: I want to restrict direct node access using node number www.example.com/node/12 and allow access using pathauto alias www.example.com/content/sometitle to anonymous user. This user should be ...
5
votes
8answers
10k views

How do I redirect users and show a message?

I want to redirect users with RedirectResponse and display a message, but the message is not displayed. $response = new RedirectResponse($url); $response->send(); After little debugging I found ...
5
votes
5answers
8k views

Redirect contact form on submit

Using Drupal 8 and trying to get the contact form to redirect to the same page after submitting. By default it seem to redirect to the home page. I have edited my themename.theme file function ...
5
votes
3answers
10k views

How do I get parameters from form redirect?

I've made a form and I'm trying to get the submit result into a redirect page with URL api: public function submitForm(array &$form, FormStateInterface $form_state) { $metier=$...
5
votes
4answers
893 views

How to get the content owned by the currently logged-in user?

A user is the owner of only one node, and I want to redirect the user, at login time, to his only owned node. How can I get the node content if I know only the logged-in user?
5
votes
1answer
2k views

How do I pass a variable via drupal_goto()?

So I have a function having http://link/to/$id as destination link. It works when I use <a href="?q=mymodule/option/$id">Targeted</a>. But I need to change it to submit form because I ...
5
votes
2answers
356 views

Build StackExchange-style url's

I'm looking for a way to build what I call 'StackExchange style' url's with Drupal 7. In my definition, that means: A node has a path alias containing both a unique identifier and the node title. For ...
5
votes
4answers
2k views

Login fails due to loop on localhost. Any ideas why?

I have git cloned a site and used Backup and Migrate to bring the database over the the local host. Working on the remote host the login works fine. Not locally. Well not anymore it worked for about ...
5
votes
1answer
497 views

How do I include ? and = in a form redirection?

I have a form and I would like to take the value from it, and use it as input for a page view which is created using exposed filters. I have created a submit handler for my first form. I then redirect ...
5
votes
3answers
3k views

RedirectResponse not working

I'm in the process of porting my modules from D7 to D8. No real problems so far, but... I have a multistep form from where I need to redirect to /node/add/xyz in the last step. (All required input ...
5
votes
2answers
4k views

using drupal sessions during hook_boot

When a user calls the front page of our site we want to check the country from which the user is surfing and redirect the user directly to the country specific front page. We chose to use the ...
5
votes
1answer
3k views

One time login redirect to password change page

In D7, How can i redirect the user when he/she use One time login. My target is after clicking one time login button user has to redirect to change password. Can any one help on this.....
5
votes
2answers
5k views

How to redirect the user to a page and show a message on the admin overlay (using drupal_set_message and drupal_goto)

I need to redirect the user to a destination and show a confirmation/error message. How can I do that? This is my code: watchdog('webform', 'The user @user has been successfully created', array('@...
4
votes
5answers
246 views

How to redirect a user to a personal area of page once logged in?

I want to allow users to login to their area 'personal' and view their uploaded images/posts (basically creating an instance of the page) which is different to every user that logs in to my website ---...
4
votes
4answers
8k views

How to do a RedirectResponse with a destination query parameter?

This works: $redirectURL = '/cart/add/p2'; return new RedirectResponse(base_path().$redirectURL); The problem is, I want this: $redirectURL = '/cart/add/p2?destination=somewhere'; The moment I ...
4
votes
4answers
5k views

Right URL rewrite after 404 redirect

Is it possible to rewrite the url in a 404 redirect according to the page which is actually being displayed ? For example, if the non-existent url "/fzenk" is requested, and you have configured the ...

1 2 3 4 5 17