Global Redirect is a simple but incredibly useful module for SEO that makes sure users are going to the correct alias of a node since nodes can be aliased in multiple ways (clean url, unclean url, node/###) and duplicate content is a no-no in the SEO world. From the module page:
- Checks the current URL for an alias and does a 301 redirect to it if it is not being used.
- Checks the current URL for a trailing slash, removes it if present and repeats check 1 with the new request.
- Checks if the current URL is the same as the site_frontpage and redirects to the frontpage if there is a match.
- Checks if the Clean URLs feature is enabled and then checks the current URL is being accessed using the clean method rather than the ‘unclean’ method. (Currently only in DEV, will be in 1.3)
The steps to get Global Redirect working are simple.
- Download the module and unzip the file into your /sites/all/modules or /sites/{yoursitename}/modules.
- Log into your drupal site with an account that has access to add modules.
- Go to Administer -> Modules (or just type in the url of admin/build/modules)
- Scroll down to the “Other” section and click on the “Enabled” checkbox next to Global Redirect.
- Click on Save Configuration
- If you already have the path module enabled you won’t see the following message. If you don’t have it enabled you’ll see a second page that ass if you would like to enable the path module. We do so hit the continue button.
- If instalation was sucessful you should see no errors and you’ll be redirected back to the module page.8. Global Redirect does not have anything to configure so there will be no additional links you need to click on.
To test if global redirect is working:
- Make sure your logged in as someone who can create nodes
- Create a node (Create Content) and give it an alias (it doesn’t matter what type of node it is page, story, whatever)
- Fill out the title and the body.
- Make sure you click on “URL path settings” and give the node a path. For this example I’m going to call mine “global_redirect_test”.
- Click on Submit
- Mouse over the edit button on the node you just created.
- In the status bar you’ll see something like “http://{your domain name}/?q=node/1/edit” or “http://{your domain name}/node/1/edit”. The number after node is the Node ID.
- Now go up to the address bar and type in “http://{your domain name}/node/{your node id number found in step 6}” or “http://{your domain name}/?q=node/{your node id number found in step 6}”
- If global redirect is working the address bar URL should change to “http://{your domain name}/global_redirect_test” or “http://{your domain name}/?q=global_redirect_test”
- If global redirect is not working the address bar will just stay as “http://{your domain name}/node/{your node id number found in step 6}” or “http://{your domain name}/?q=node/{your node id number found in step 6}”
A quick note about caching & Global Redirect. Since Global Redirect needs to be loaded on every page load the maximum setting you can have for caching in the performance section (admin/settings/performance) is Normal. If your Caching mode is set to “Aggressive” Global Redirect will not work.