Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Have not found this in my searches on SE.

I need this scenario to work:

• User visits someurl.com/news/folder or someurl.com/news/somefolder/, they get redirected to someurl.com/somefolder.

• If the user visits JUST someurl.com/news or /news/, they are allowed through to visit /news.

Here is my current rule: RewriteRule ^news/(.*) /$1 [NC,R=301,L]

How do I make it allow the second bullet point? First seems to work with no issues.

Thanks all!


I have got the code

RewriteCond %{REQUEST_URI} ^news RewriteRule ^/news news/ [NC,L]

RewriteCond %{REQUEST_URI} ^/news/(.)$ RewriteRule ^news/(.) /$1 [NC,R=301,L]

BUT - it doesn't allow me to go to the URL something.com/news/

Any thoughts?

share|improve this question

Instead of .* in your rewrite rule use .+ The star means zero or more characters, the plus means there has to be at least one.

 RewriteRule ^news/(.+) /$1 [NC,R=301,L]

Then you don't have any problems with that rewrite rule interfering with /news or /news/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.