Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:28:01+00:00 2026-05-27T20:28:01+00:00

This is my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Remove multiple

  • 0

This is my .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Remove multiple slashes anywhere in URL
    RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
    RewriteRule . %1/%2 [R=301,L]

    # Never use www prefix!
    RewriteCond %{HTTP_HOST} ^www.domain\.org [NC]
    RewriteRule (.*) http://domain.org/$1 [R=301,L]

    # Remove multiple slashes after domain
    RewriteRule ^/(.*)$ http://domain.org/$1 [R=301,L] 

    # Remove trailing slash in some cases
    RewriteRule ^(.*)\.css/$ http://domain.org/$1.css [L,R=301]
    RewriteRule ^(.*)\.js/$ http://domain.org/$1.js [L,R=301]
    RewriteRule ^(.*)\.jpg/$ http://domain.org/$1.jpg [L,R=301]
    RewriteRule ^(.*)\.jpeg/$ http://domain.org/$1.jpeg [L,R=301]
    RewriteRule ^(.*)\.png/$ http://domain.org/$1.png [L,R=301]
    RewriteRule ^(.*)\.gif/$ http://domain.org/$1.gif [L,R=301]
    RewriteRule ^(.*)\.xml/$ http://domain.org/$1.xml [L,R=301]

    # Force trailing slash
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !index.php
    RewriteCond %{REQUEST_URI} !(.*)\.css
    RewriteCond %{REQUEST_URI} !(.*)\.js
    RewriteCond %{REQUEST_URI} !(.*)\.jpg
    RewriteCond %{REQUEST_URI} !(.*)\.jpeg
    RewriteCond %{REQUEST_URI} !(.*)\.png
    RewriteCond %{REQUEST_URI} !(.*)\.gif
    RewriteCond %{REQUEST_URI} !(.*)\.xml
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://mydomain.org/$1/ [L,R=301]

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

    # MIME types
    AddType text/css .css
    AddType text/javascript .js

    # Enable compression
    AddOutputFilterByType DEFLATE text/html text/plain text/css     text/javascript text/x-css text/x-javascript text/x-js text/htm application/x-javascript application/javascript application/js application/x-js image/png image/gif image/jpg image/jpeg

    #Skip browsers with known problems
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    php_flag display_errors on
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

But, when I go to **/////, the trailing slashes will not go away. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:28:01+00:00Added an answer on May 27, 2026 at 8:28 pm

    The %{REQUEST_URI} variable gets reduced of extra slashes when it gets prepped. So the condition RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ will never match because for a request like http://domain.org////, the REQUEST_URI variable gets reduced to just /. Try using the THE_REQUEST variable:

    RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ (.*)//([^\ ]*)
    RewriteRule ^ %2/%3 [R=301,L]
    

    Additionally, the prefix (the leading slash) gets stripped off of the request URI when rewrite rules are in an htaccess file, so the rule RewriteRule . %1/%2 [R=301,L] would never match because the regex . requires at least one character to match. When the URI is / and the leading slash gets stripped, the URI that’s used to match in the url is a blank string. So using ^, or (.*), or something equivalent of “everything including nothing” regex needs to be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this htaccess code: RewriteEngine on RewriteBase /xm/ RewriteCond %{REQUEST_URI} !^/index.php$ RewriteRule ^([a-z0-9]*)\.php$
I have this in my .htaccess file: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On
Currently I have these rules in my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule
I'm redirecting this URL: http://mydomain.com/expandyourtaste Using this .htaccess file: #Expand your tastes redirects Redirect
I have the following code in my htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} !^www.example.com$
So I have this .htaccess file in the /blog/ folder on my webserver and
I was spoon fed this htaccess file from Gumbo and I am grateful for
I have this .htaccess file in WordPress. It's located at /public_html/ (web root). I
The htaccess file below crashed the site with an internal server error (500). This
I use this line in my .htaccess file to automatically add a trailing slash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.