htaccess rewrite code

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
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

htaccess rewrite code

Post by rajsekar2u »

hi,

Am creating a website. the url of the site looks like below

http://www.example.php

I want to convert it into http://www.example.htm using .htaccess rewite. How to do it.
And also i want to change the following url

http://www.example.php?cmd=201

to

http://www.example.php

how do this with .htaccess rewrite

Please help me
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: htaccess rewrite code

Post by superdezign »

Have you tried searching Google for "htaccess mod_rewrite"?
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

Re: htaccess rewrite code

Post by rajsekar2u »

Ya i've found something. But dont know which one to use.
Please guide me in this. Caz i haven't used htaccess yet. this is the first time.

Thanks in advance.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: htaccess rewrite code

Post by requinix »

http://www.example.htm and http://www.example.php aren't valid. Want to try saying it again?
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

Re: htaccess rewrite code

Post by rajsekar2u »

http://example.php?cmd=somevalue

In the above url i want to hide ?cmd=somevalue

Is it possible in htaccess or any otherway
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: htaccess rewrite code

Post by amargharat »

your url is wrong, you are saying http://example.php?cmd=value

it should be http://www.domain.com/example.php?cmd=value
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

Re: htaccess rewrite code

Post by rajsekar2u »

Sorry. I wrongly entered it.

The correct url is : http://www.domain.com/example.php?cmd=value

In this i want remove the value "cmd=value".

But i want the value of "cmd" in example.php page.
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: htaccess rewrite code

Post by amargharat »

current url

http://www.domain.com/example.php?cmd=value

if you want to do rewrite in a following manner
http://www.domain.com/example/value

then in htaccess just write following line

Code: Select all

RewriteRule example/(.*)$ example.php?cmd=$1 // for numeric => ([0-9]+), for alphabets ([a-z]+)
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

Re: htaccess rewrite code

Post by rajsekar2u »

Thanks.

I've another doubt.

http://www.domain.com/folder/example.php?cmd=value

If the url is like below what to change on below

Code: Select all

RewriteRule example/(.*)$ example.php?cmd=$1 // for numeric => ([0-9]+), for alphabets ([a-z]+)
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: htaccess rewrite code

Post by amargharat »

Code: Select all

RewriteRule folder/example/(.*)$ folder/example.php?cmd=$1 // for numeric => ([0-9]+), for alphabets ([a-z]+)
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: htaccess rewrite code

Post by amargharat »

Code: Select all

RewriteRule folder/example/(.*)$ folder/example.php?cmd=$1 // for numeric => ([0-9]+), for alphabets ([a-z]+)
rajsekar2u
Forum Commoner
Posts: 71
Joined: Thu Nov 20, 2008 4:23 am

Re: htaccess rewrite code

Post by rajsekar2u »

Thanks
Post Reply