Reputation: 337
I have a website. I want to my site seo friendly. For that I used .htacces rewrite rule for making custom seo friendly url.
I want when I put url i.e http://nila.mobi/services it will shows the content of file http://nila.mobi/services.php.
There have same page structure like that. I used the code on .htacces file which I write on bellow.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Where am I wrong. Please help me.
Upvotes: 0
Views: 77
Reputation: 784898
Reorder your rules and add L
flag:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Upvotes: 1