Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
share|improve this question

migrated from stackoverflow.com Jun 21 '11 at 7:19

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 0 down vote accepted

You 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
share|improve this answer
    
I tried this, but the result is the same, When I enter thinkmovie.in/index.php/latestnews/272, The url in the browser has to remain the same, but the content should be from, thinkmovie.in/index.php/latestnews?nid=272 –  Napster Jun 21 '11 at 20:04
    
Sorry i had to disable joomla's "use clean urls" for this to be working. Its working just fine. Thanks for the help –  Napster Jun 22 '11 at 21:36

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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