• How To?
  • Tips ‘n Tricks
  • WordPress
  • Snippets
  • Software
    • Browsers
    • Downloads
  • Web
  • Tools
    • Character Counter
    • chmod Calculator
    • Entities Encoder
    • Live HTML Editor
    • My IP
  • Contact
Twitter Facebook Google+ RSS
You are here: SumTips » Snippets » htaccess Snippets » Exclude Certain Folders from htaccess Rewrite Rules

Exclude Certain Folders from htaccess Rewrite Rules

Posted on December 4, 2011 by Renji | Short URL: http://sumtips.com/?p=5984

If you have an application or CMS running, you might have SEO url’s enabled through .htaccess rewrites. Now installing a second application in a subfolder on the same domain can cause 404 errors. This is because all subfolders follow the rules specified in the root htaccess file.

To prevent the errors, there is a single line which you can add to exclude such a foldername from being rewritten. Below a default .htaccess file for WordPress:

To prevent the errors, you can add the below single line to your rewrites to exclude that particular application folder.

RewriteCond %{REQUEST_URI} !^/(folder1|folder2/.*)$

Simply replace “folder1″ with your own subfolder name that needs to be excluded from the rewrite.

In a default WordPress installation, it would look like this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(folder1|folder2/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


Tweet

Related posts:

  • Test Your htaccess Rules Online
  • 35 .htaccess Hacks for Web Developers
  • Edit .htaccess File Inside the WordPress Dashboard
  • Force Download Files on your Website using htaccess
  • Exclude Specific Post, Category and Author from WordPress Feed
Categories: htaccess Snippets
Ultimate htaccess Redirects List

One Response to “Exclude Certain Folders from htaccess Rewrite Rules”

  1. brad.tittle says:
    February 21, 2012 at 2:02 AM

    I first started doing this with Rails. At the top of the rails .htaccess are the following two lines.

    # RewriteCond %{REQUEST_URI} ^/notrails.*
    # RewriteRule .* – [L]

    When I finally followed their example it worked.

    I wanted to exclude images, javascripts, stylesheets, css, images-global, js-global (etc) so I changed the above to.

    RewriteCond %{REQUEST_URI} ^(images|javascripts|stylesheets|css|images-globa|js-global|js).*
    RewriteRule .* – [L]

    And it worked the way I needed.

    We won’t talk about how it is that I have so many different javascript, stylesheet and images folders….

    But this does make my “error” file less painful. If someone adds an image file that doesn’t exist, my dispatch doesn’t have to process it.

  • Get Updates via Email

  • Recent Posts

    • CMS2CMS: Migrate Site from Drupal or Joomla to WordPress
    • WordPress: Add Preview Button in Distraction Free Writing
    • How to Activate or Deactivate Individual Jetpack Modules
    • Windows 8: Auto Update Defender with Windows Update Disabled
    • Automatically Start and Close Programs at Specific Time
    • How to Copy Code from Notepad++ with Syntax Highlighting
  • Random Posts

    • How to Create Portable Shortcut with Relative Path in Windows
    • Test Integrity and Size of USB Flash Drives And Hard Drives
    • Change Windows 8 Screenshot Save Location
    • Disable All Chrome Extensions & Apps With a Single Click
    • Move Office MSOCache Folder to Another Drive
    • Add Pages, Custom Post Types in WordPress Site Feed
  • Categories

    • Blogging
    • Games
    • Google
    • How To?
    • Linux
    • Microsoft
      • Windows
    • Miscellaneous
    • Phone
    • Snippets
      • AutoHotkey Snippets
      • CSS Snippets
      • htaccess Snippets
      • JavaScript Snippets
      • PowerShell Snippets
      • WordPress Snippets
    • Social
    • Software
      • Browsers
    • Tips 'n Tricks
    • Wallpapers
    • Web
© SumTips. Contact | Sitemap | Privacy Policy