I have a few URLs and I need them to be rewrite'd to the ones below:

http://domain.net/blog/posts
http://domain.net/blog/posts/index
http://domain.net/blog/posts/view/uri/non-working-holiday
http://domain.net/blog/posts/view/uri/we-no-longer-offer
http://domain.net/blog/posts/view/uri/festivals
http://domain.net/blog/posts/view/uri/christmas-is-just-around-the-corner

http://domain.net/posts/
http://domain.net/posts/index
http://domain.net/posts/view/uri/non-working-holiday
http://domain.net/posts/view/uri/we-no-longer-offer
http://domain.net/posts/view/uri/festivals
http://domain.net/posts/view/uri/christmas-is-just-around-the-corner

I was hoping that my .htaccess will fix this but it doesn't:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteRule ^blog\/(.*)$ posts\/$1  [NC]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
link|improve this question
feedback

1 Answer

up vote 0 down vote accepted
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteRule ^blog/(.*)$ /posts/$1  [R=301,L]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule ^(.*)$ index.php [QSA,L]
link|improve this answer
It may need to be RewriteRule ^blog/posts/(.*)$ /posts/$1 [R=301,L] – becomingwisest Mar 19 '11 at 2:44
feedback

Your Answer

 
or
required, but never shown

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