Apply rewrite rule for all but all the files (recursive) in a subdirectory?

Posted by user784637 on Server Fault See other posts from Server Fault or by user784637
Published on 2013-10-28T21:07:23Z Indexed on 2013/10/28 21:55 UTC
Read the original article Hit count: 138

Filed under:
|
|

I have an .htaccess file in the root of the website that looks like this

RewriteRule ^some-blog-post-title/ http://website/read/flowers/a-new-title-for-this-post/ [R=301,L]
RewriteRule ^some-blog-post-title2/ http://website/read/flowers/a-new-title-for-this-post2/ [R=301,L]

<IfModule mod_rewrite.c>
RewriteEngine On

## Redirects for all pages except for files in wp-content to website/read
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/wp-content
RewriteRule ^(.*)$ http://website/read/$1 [L,QSA]

#RewriteRule ^http://website/read [R=301,L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
  1. My intent is to redirect people to the new blog post location if they propose one of those special blog posts.
  2. If that's not the case then they should be redirected to http://website.com/read.
  3. Nothing from http://website.com/wp-content/* should be redirected.

So far conditions 1 and 3 are being met. How can I meet condition 2?

© Server Fault or respective owner

Related posts about apache2

Related posts about mod-rewrite