I am trying to rewrite a few links with htaccess

Posted by Thorpe Obazee on Server Fault See other posts from Server Fault or by Thorpe Obazee
Published on 2011-01-03T12:14:48Z Indexed on 2011/01/03 12:56 UTC
Read the original article Hit count: 232

Filed under:
|

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

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about .htaccess