ReWrite Pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jigneshsoni
Forum Newbie
Posts: 1
Joined: Tue Aug 11, 2009 4:03 am

ReWrite Pages

Post by jigneshsoni »

Hello Guys,
I have trouble with url re-writing,
I am new to php, for SEO purpose i want to change few of my site's pages from .php to .htm/.html

i want to change below four pages from .php to .htm
index.php, contact.php, aboutus.php, career.php
can you please help me to re-write above pages.

i have tried using below re-write script, but failed :(

RewriteEngine on

RewriteRule ^(.*)\.htm$ aboutus.php [NC]
RewriteRule ^(.*)\.htm$ index.php [NC]
RewriteRule ^(.*)\.htm$ contact.php [NC]
RewriteRule ^(.*)\.htm$ career.php [NC]


Also if you could suggest me some good books/links for rewrite rules
ct_lee
Forum Newbie
Posts: 12
Joined: Wed Aug 05, 2009 3:15 pm

Re: ReWrite Pages

Post by ct_lee »

This code should work:

Code: Select all

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]
If you then try to go to index.htm or aboutus.htm it will show the relevant php page. All you need to do is change the links in your pages so they link to .htm pages not .php pages.

Hope that helps.
Post Reply