RewriteURL

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
myinnet
Forum Newbie
Posts: 3
Joined: Thu Jun 08, 2006 7:49 pm

RewriteURL

Post by myinnet »

i need help, i have a table, like :
******
id, topic, content
******

on the page, it normally show like this one:
<a href=view.php?id=1>This is a test</a>

i would like this link looks like:

<a href=this_is_a_test_1.html>This is a test</a>

How to do that?
thanks
MyInnet
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I really don't get what your asking...
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

Unless I'm mistaken, you want to use Apache's mod_rewrite module.

I'm somewhat familiar with this method, having used it in a couple of instances, but I'm quite sure the exact URL you want isn't quite possible. You'll normally change a URL like

Code: Select all

<a href="view.php?id=1">test</a>
to

Code: Select all

<a href="view/1/">test</a>
myinnet
Forum Newbie
Posts: 3
Joined: Thu Jun 08, 2006 7:49 pm

Post by myinnet »

bdlang wrote:Unless I'm mistaken, you want to use Apache's mod_rewrite module.

I'm somewhat familiar with this method, having used it in a couple of instances, but I'm quite sure the exact URL you want isn't quite possible. You'll normally change a URL like

Code: Select all

<a href="view.php?id=1">test</a>
to

Code: Select all

<a href="view/1/">test</a>
This is ok, but how to write the rules, and .htaccess.
thanks
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

myinnet wrote: This is ok, but how to write the rules, and .htaccess.
thanks
Different forum, possibly different website, definitely different user. ;)
myinnet
Forum Newbie
Posts: 3
Joined: Thu Jun 08, 2006 7:49 pm

Post by myinnet »

what your mean? can you tell me how to do that?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

bdlang wrote:Unless I'm mistaken, you want to use Apache's mod_rewrite module.

I'm somewhat familiar with this method, having used it in a couple of instances, but I'm quite sure the exact URL you want isn't quite possible. You'll normally change a URL like

Code: Select all

<a href="view.php?id=1">test</a>
to

Code: Select all

<a href="view/1/">test</a>
No, it is entirely possible. The thing to remember is that mod_rewrite is not rewriting your URL. It is using a regex rule to take what is in the address bar into and translate that into something else while leaving the address bar alone. As an example, it could take the URL ...

Code: Select all

<a href="this-is-a-file,withaquerystring,separated,by,commas.holycowpaddies">Hello World</a>
And pipe the page to this_is_a_file.php?qs=querystring&sep=separated&how=by&what=commas without the user seeing a change in the URL address bar in their browser.

To the original poster, google search for 'mod_rewrite tutorials', check out the mod_rewrite cheat sheet and also have a look in this community, notably under the Apache, IIS, Web Servers forum.
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

Thanks, Everah. :)
Post Reply