Reputation: 189
I have been working on PHP gallery and creating 'pretty URLs'. But before going with the .htaccess route, I would like to see if I can clean up my link using PHP. I am sorry if this sounds so stupid but wanted to see if I can change my link from
rajeevthomas.com/viewgallery.php?cname=Colorado-Fall&pcaption=Early-Colors
to
rajeevthomas.com/viewgallery.php/Colorado-Fall/Early-Colors
using just PHP?
Right now this bit of code creates the link.
$result_final .= "<div class=limage><table><tr><td><table class=image><tr>\n\t<td><a href=/viewgallery.php?cname=$cname&pcaption=".$caption_array[$next]."><img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_keywords."' /></a>
Or is this impossible since the link is being created by data pulled from the database?
Upvotes: 0
Views: 209
Reputation: 3844
Yes you can, but you should modify both .htaccess file and index.php file.
Modify .htaccess file is for the server to understand the routing and index.php file is for application side.
Sample .htaccess file as follows,
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
Just go through this tutorial. Then you can get an idea how to do that.
Upvotes: 1