homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod_rewrite help
hswaseer




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

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




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

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




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

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




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

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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved