ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Help adding trailing slashes to URLs

February 15, 2008 8:47pm

Subscribe [2]
  • #1 / Feb 15, 2008 8:47pm

    ashuttl

    17 posts

    Hi there,

    I’m looking for some help in adapting this piece of code, which adds www to non-www URLs and simultaneously adds trailing slashes to URLs that don’t have them. I’ve copied the relevant parts below:

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_URI}\\/%{HTTP_HOST}/www. ^/+(.+/)?[^.]*[^/]\\(/)([^w][^w][^w][^.].*/(www\.)|.*)$ [OR,NC]
    RewriteCond %{HTTP_HOST}/www. ^(/)?(/)?([^w][^w][^w][^.].*/(www\.))$ [NC]
    RewriteRule ^ http://%4%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]

    How to I adapt this to add the trailing slashes but remove or leave untouched the www part of the URL?

    I’m less adept at reading Apache code than I’d like to be. (Any good resources on this, BTW?)

  • #2 / Feb 16, 2008 7:19pm

    mayest

    293 posts

    Andrew, the best place for Mod_Rewrite help is the Apache Forum at webmasterworld.com. Do a Google search on trailing slashes with site:webmasterworld.com and you should come up with something right away.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases