Sign up ×
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]+)/$$1 [L]
RewriteRule latestnews/([a-zA-Z0-9]+)$$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
share|improve this question

migrated from 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

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
share|improve this answer
I tried this, but the result is the same, When I enter, The url in the browser has to remain the same, but the content should be from, –  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]
share|improve this answer

Your Answer


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.