Question

We are using the Redirect module 8.x-1.2 with Drupal 8.5.6. When generating URLs, we are finding that a trailing slash is added to the end of the URL, and this is creating a 503 error code.

How would I redirect the anonymous users from the URL with the trailing slash to the one without trailing slash?

Was it helpful?

Solution

Check your .htaccess file in root. There maybe a line that is overriding this rule. Check if this is in your .htaccess file, this forces a trailing slash.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule ^ /%1 [R=301,L] 

To remove the trailing slash use

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R]

If the Drupal setting is not being enforced then you may have a rule in your .htaccess file that is adding a slash. @usernameabc Try adding the last 2 lines under RewriteEngine on

OTHER TIPS

Select the Enforce clean and canonical URLs checkbox in admin/config/search/redirect/settings.

Enabling this will automatically redirect to the canonical URL of any page. That includes redirecting to an alias if existing, removing trailing slashes, ensure the language prefix is set and similar clean-up.

screenshot

In my case, whenever I accessed a url, four slashes were automatically appended to the url (IP////<node_name).

Following steps resolved my issue:

  1. Ensure that following entry is available in Apche configuration file - httpd.conf. LoadModule rewrite_module modules/mod_rewrite.so
  2. Create a php file test.php with the following code. <?php echo phpinfo(); ?>
  3. Open test.php in your browser. Check the Loaded Modules section to ensure that mod_rewrite is available.
  4. Also open the root Drupal PIP folder and ensure that .htaccess folder is there.
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top