Page 1 of 1
little help on mod_rewrie!
Posted: Mon Mar 13, 2006 12:56 am
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.
Posted: Mon Mar 13, 2006 1:05 am
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
Posted: Mon Mar 13, 2006 5:31 am
by heerajee
feyd | Please use 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
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Mon Mar 13, 2006 6:01 am
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...";
?>
Posted: Mon Mar 13, 2006 11:24 am
by feyd
for all the non-aolspeakers heerajee wrote:feyd | Please use 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
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/quote]