I am trying to implement clean URLs using .htaccess.

Basically after searching for some time I found out this code

RewriteRule latestnews/([a-zA-Z0-9]+)/$ http://thinkmovie.in/index.php/latestnews/?nid=$1 [L]
RewriteRule latestnews/([a-zA-Z0-9]+)$ http://thinkmovie.in/index.php/latestnews/?nid=$1 [L]

so when I try to access the following URL


it redirects to


But what I want is to retain the URL in the browsers address bar as


2 Answers 2


Your URLs don't really make sense to me, but here is some code that I think looks like what you want to do.

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^latestnews/([^/]+) /index.php?nid=$1

Have you actually tested this? It should work how you want it to - your server shouldn't be returning a 301 or 302 to redirect the user to the new URL. I have the following .htaccess for a cakePHP application and it appends everything after the domain to 'index.php?url=' if the requested file doesn't exist.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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