Changing PHP links, to fully output mod rewrite...

Discuss practical ways rearrange URLs using mod_rewrite.

Changing PHP links, to fully output mod rewrite...

Postby cl4im3r » Wed Jun 11, 2008 9:58 am

Hello, I have recently been told that Mod _rewrite doesn't actually change the Links on your site.

Here is my Rewrite Rule, Provided by 'RichardK'

Code: Select all
RewriteEngine On

# Don't match existing files.
RewriteCond %{SCRIPT_FILENAME} !-f
# Don't match existing directories.
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /article.php?titleurl_art=$1 [QSA,L]


This makes site.co.uk/article.php?titleurl_art=portal

Appear as site.co.uk/portal

Now the only thing i need to do is change my PHP site link, in order for my links to output the new rewrite.

Here is my PHP Link.
<a href="../topic.php?titleurl_art=<?php echo $row_rsNo['titleurl_art']; ?>">

How would i edit this PHP link, for mod rewrite to output the rewritten friendly URL?

Thanks in Advance! :D
cl4im3r
 
Posts: 15
Joined: Mon Jun 09, 2008 10:28 am

Postby richardk » Wed Jun 11, 2008 3:15 pm

That link is for topic.php not article.php, but the general idea is that you have
Code: Select all
<a href="../topic.php?titleurl_art=<?php echo $row_rsNo['titleurl_art']; ?>">

and the part of the URL you want to remove is "topic.php?titleurl_art=", so you get
Code: Select all
<a href="../<?php echo $row_rsNo['titleurl_art']; ?>">
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 54 guests

cron