RewriteRule for URL Subdirectory Root
Posted
by
JYerdon
on Pro Webmasters
See other posts from Pro Webmasters
or by JYerdon
Published on 2012-11-30T13:54:50Z
Indexed on
2012/11/30
17:21 UTC
Read the original article
Hit count: 208
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!
POST UPDATE
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?
© Pro Webmasters or respective owner