WarpConduit Computing

  • Quick Tips
  • Web Design & Development
  • Graphic Design
  • Home
  • WordPress Plugins
  • Password Generator
  • About
  • Contact

RewriteRule and Trailing Slashes

May 7, 2010 by Josh Hartman

Just a quick post today, i needed to redirect a URL with and without a trailing slash to the same destination, but didn’t want to create two separate rules, so I did some searching and found that it is very simple.

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^video(/)?$ http://video.somedomain.com [R=301,L]

RewriteCond %{HTTP_HOST} ^.*$ RewriteRule ^video(/)?$ http://video.somedomain.com [R=301,L]

The (/)? is the key to matching a url with or without a trailing slash.

Filed Under: Web Design & Development Tagged With: htaccess, rewriterule, slashes

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • Extremely Useful Applications for Web Development and IT Tasks
  • Installing BookStack Wiki on cPanel Shared Hosting
  • Media (MIME) Type Reference List

Tags

automatic base64 benchmark cache counter css deflate email font gzip htaccess html image inarray increment inline images in_array javascript jquery link list magento mailto menu metadot mysql number obfuscation opencart operating system order php random redirect rewriterule slashes software timestamp ubuntu unix upgrade url windows windows 7 wordpress

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2021 WarpConduit Computing. All Rights Reserved.