Results 1 to 2 of 2

Thread: How to Rewrite to Remove Double or Multiple Slashes (//) in URL

  1. #1
    Join Date
    Dec 2004
    Posts
    420

    How to Rewrite to Remove Double or Multiple Slashes (//) in URL

    Google search engine spider or crawler Googlebot is one of the most advanced and finest content grabber that extracts most if not all of any data of the Internet and World Wide Web, regardless of whether such contents or web pages are intended for public visitors.

    As such, some webmasters may notice that Google is crawling and indexing web pages which are not supposed to be existed in the first place. One such instance is incorrect and wrong URL link location, such as when double slash, triple slash or multiple forward slashes been formed as part of the URL as extra slash or slashes been appended or added to the web page URLs. For example, a page with URL of http://www.domain.com/index.php is also been crawled by Google as http://www.domain.com//index.php, or sometimes even http://www.domain.com///index.php.

    The web crawl and spider indexing by Google can be tracked and traced in Apache or web server access logs. And these double slash, triple slash, quadruple or more slash URLs can show up in the Google search results, and potentially can cause duplicate content issue , and worse, penalty that makes the site vanishing from Google search results listing or been pushed into supplemental results with low ranking.

    The reason for additional slashes in the URL is unknown, and seems like it only happens on Google search engne. One possibility is visitors or other websites type or put incorrect backlink (external link), which picked up by ultra-sensitive Googlebot or Mediapartners-Google (Google AdSense crawler which also contribute website indexing of Google Search). But one thing is for sure - when one page with wrongful double or a few adjacent slashes been indexed, entire web pages within the website may be prone to such error too.

    To fix and resolve the double slash or multiple slash URLs issue is pretty simple. Simply create a mod_rewrite directive in .htaccess code or Apache httpd.conf configuration file to rewrite or redirect permanently (status 301) all URL found to be contained two or more adjacent or trailing slashes to its proper and valid URL with just a single slash (/) instead or // or /// or even //// or more within the URL address, create a .htaccess file in the root directory (normally public_html) for the website with the following URL rewriting and redirection directive (if .htaccess already exists, just add in the code on top).

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


    The above redirection or URL rewrite method will parse the complete URL section on the part after the domain name, and will change each part of double slash to single slash (and thus able to handle more than 2 slashes in URL too). For administrators who want to more efficient rewrite command, use the following code, which can only be used on .htaccess file.

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

    Replace domain name accordingly.

  2. #2
    Join Date
    May 2009
    Posts
    1

    Re: How to Rewrite to Remove Double or Multiple Slashes (//) in URL

    Hi Dr. Jones,

    First two lines work very well. It trims extra slashes but emails get stop. Means registration email, forget password email alert don't go if I add that particular code in .htaccesss file. Can you please fix this issue..

    Thanks

Similar Threads

  1. RIM slashes Blackberry prices up to 26%
    By Addis in forum Web News & Trends
    Replies: 1
    Last Post: 29-03-2012, 12:36 PM
  2. How to print multiple double sided sheets from Microsoft Excel
    By Holly Dayin in forum MS Office Support
    Replies: 5
    Last Post: 17-02-2012, 02:01 PM
  3. Replies: 7
    Last Post: 28-12-2011, 05:18 PM
  4. Replies: 3
    Last Post: 04-03-2011, 07:58 AM
  5. Ping Mobile slashes ISD Rates
    By TEcH GuRuJI in forum India BroadBand
    Replies: 2
    Last Post: 10-12-2008, 01:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,582,512.96478 seconds with 16 queries