Forum Moderators: phranque
If you want to turn visit_link.php?id=10486 into visit_link_10486.php
then you could use
RewriteRule ^visit_link_(.*)\.php$ /visit_link\.php?id=$1
This will change all of your static type links into dynamic links to use with your php code.
For search engines you do need to change all of the links in your html code to the 'static' version of the link. Then use the mod_rewrite to make them dynamic for use with php.
[httpd.apache.org...]
[httpd.apache.org...]
Will help you get around the mod_rewrite
I am almost done, but I am stuck when I want to include my link title to the URL, because the link tile is more than one word so the URL comes with SPACE. I assume that I need to fill the SPACE with hyphens (-)
Following is the way my URLs are generated
{ echo '<a href="'.$site_url.'/visit_link.php?id='.$row['id'].'">'.$row['name'].'</a>'; }
How can I change this code to have the URL to be filled with hyphens instead of SPACE?
My original URL is
[mydomain.com ]
My .htaccess is following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /RewriteRule ^visit_link_(.*)\.html$ /visit_link\.php?id=$1
</IfModule>
This is producing the URL as:
[mydomain.com ]
How can I produce the following URL?
[mydomain.com ]
Ad you can see "Go-to-3D-model-look.html" is the name of the link
You're describing this incorrectly, since it is your PHP script that is "producing" the URL, and the URL is "defined" for the WWW when it appears on your pages.
So your mod_rewrite code isn't "producing" anything -- It is simply "connecting" the search-friendly URL produced by your PHP code back to the script filepath inside your server, so that your script can generate the next page.
The whole process is a whole lot easier to understand if you understand and use the description above.
Because mod_rewrite doesn't have to 'produce' anything, all your mod_rewrite code will have to do is to discard the 'keywords' part of the search friendly URL added by your php script.
example.com/10486/<letters and hyphens>.html --> /visit_link.php?id=10486 :
RewriteRule ^([0-9]+)/[a-z\-]+\.html$ /visit_link\.php?id=$1 [NC,L]
[edited by: jdMorgan at 7:26 pm (utc) on Nov. 4, 2007]