little help on mod_rewrie!

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
heerajee
Forum Newbie
Posts: 18
Joined: Sat Feb 25, 2006 12:33 am

little help on mod_rewrie!

Post by heerajee »

Hi,

I think the mod_rewrite only works when we give the address in the address bar of static page manually.
what if i have http://www.abc.com website that has a link Contactus and takes me to the contactus.php and the address bar shows the address as http://www.abc.com/contactus.php,
but i want that the address bar showed the address as http://www.abc.com/contactus on this page with the help of mod_rewrite.

I am very thankful to you for this and have wasted 1 weak for this.
Thanks.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

RewriteBase /
RewriteEngine On

RewriteRule ^/contactus$ /contactus.php
or more preferably, make all your links more friendly

Code: Select all

RewriteBase /
RewriteEngine On

RewriteRule ^([A-Za-z]+)$ index.php?page=$1
heerajee
Forum Newbie
Posts: 18
Joined: Sat Feb 25, 2006 12:33 am

Post by heerajee »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I think u could not get understand my point or u dont know the right code for this condition.
index1.php

Code: Select all

<?php 
print "This is index1.php file....";
?>
<a href="contactus.php">Click here</a>
index1.php

Code: Select all

<?php 
print "This is contact us file...";
?>
index1.php is main page,when the user clicks on the "click here", goes to the contact.php and the address bar shows the address as http://www.abc.com/contactus.php
but i want that the address bar showed the address as http://www.abc.com/contactus.

Now if u know, plz inform me.
Thanks.


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

The RewriteRule Jcart gave seems correct to me.
However you should change the url in the link as well:
index1.php

Code: Select all

<?php
print "This is index1.php file....";
?>
<a href="/contactus">Click here</a>
contactus.php

Code: Select all

<?php
print "This is contact us file...";
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

for all the non-aolspeakers heerajee wrote:feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I think [color=red]you[/color] could not get understand my point or [color=red]you[/color] don[color=red]'[/color]t know the right code for this condition.
index1.php

Code: Select all

<?php 
print "This is index1.php file....";
?>
<a href="contactus.php">Click here</a>
index1.php

Code: Select all

<?php 
print "This is contact us file...";
?>
index1.php is main page,when the user clicks on the "click here", goes to the contact.php and the address bar shows the address as http://www.abc.com/contactus.php
but i want that the address bar showed the address as http://www.abc.com/contactus.

Now if u know, plz inform me.
Thanks.


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/quote]
Post Reply