Welcome to WebmasterWorld Guest from 54.147.44.93

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite help

     

hswaseer

12:25 pm on Jan 17, 2004 (gmt 0)

10+ Year Member



Hi

How should i write mod_rewrite code for the following -

I want my url to look like this -

<a href=http://www.test.com/soccer/name/sweety>
<a href=http://www.test.com/soccer/name/john>

The name 'sweety' and 'john' each will change according to the link clicked. Like if someone click on link '1' the url_window should show 'sweety' and when someone click on link '2' the url_window should show 'john'

if($id==1)
{
echo "one";
}

if($id==2)
{
echo "two";
}

echo "
<a href=http://www.test.com/soccer/name?id=1>1</a>
<a href=http://www.test.com/soccer/name?id=2>2</a>

";

Thanks

HS

RonPK

5:38 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HS, I don't get it. mod_rewrite is often used to rewrite pretty URLs to something only server-side apps like, without the user seeing any change in the browser's address bar. Is that what you're after? If so, there are plenty of examples on the web and on this board. If not, please explain what you're after...

hswaseer

10:34 am on Jan 19, 2004 (gmt 0)

10+ Year Member



hi

Along with clean urls i want my urls to be user friendly also so that then can directly type the url containing their name and can directly go to their page ...like

www.test.com/soccer/name/john

The code which i am writing is as follows

if(id==1)
{
do bla bla..
}

<a href=$PHP_SELF?id=1>John</a>

Now what should be the mod_rewrite code

HS

RonPK

2:01 pm on Jan 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, create a rewrite rule that requests

yourphp.php?cat=soccer&name=john

whenever a user asks for

www.test.com/soccer/name/john

yourphp.php should then query your soccer database to find out whether there is someone called john.

<a href=$PHP_SELF?id=1>John</a>

I really must be missing something: I thought you wanted to use nice urls...
<a href=/soccer/name/john>John</a>
 

Featured Threads

Hot Threads This Week

Hot Threads This Month