0

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

http://thinkmovie.in/index.php/latestnews/272

it redirects to

http://thinkmovie.in/index.php/latestnews?nid=272

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

http://thinkmovie.in/index.php/latestnews/272
0

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
|improve this answer|||||
0

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]
</IfModule>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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