svk
svk

Reputation: 4553

How can I make the URL search engine friendly?

I want to cahange mysite.com/profile.php into mysite.com/profile

I wrote the htacess file as

RewriteEngine On 

RewriteRule ^profile/?$ profile.php [NC,L]

and placed in root directory. It doesn't work. I use the apache server. What is wrong with my program?

Upvotes: 0

Views: 166

Answers (1)

mpen
mpen

Reputation: 282825

Try something like this instead:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

That way you dont have to do it for each individual URL.

credit

Upvotes: 3

Related Questions