Forum Moderators: phranque

Message Too Old, No Replies

How to make dynamic pages look static without mod rewrite?

         

smartcard

6:13 pm on Nov 2, 2007 (gmt 0)

10+ Year Member



My PHP is using following way to refer pages:
visit_link.php?id=10486

How can I make it SEO Friendly?

PHP_Chimp

6:15 pm on Nov 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there any specific reason why you cant use mod_rewrite?
As that would be a lot easier.

smartcard

6:38 pm on Nov 2, 2007 (gmt 0)

10+ Year Member



Frankly the reason is I don't know any coding.

PHP_Chimp

7:50 pm on Nov 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ask on the Apache forum to get complete help, but here is an example -

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

smartcard

7:42 pm on Nov 3, 2007 (gmt 0)

10+ Year Member



Thanks for all your help.

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?

smartcard

6:48 pm on Nov 4, 2007 (gmt 0)

10+ Year Member



More details here :

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

jdMorgan

7:25 pm on Nov 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



smartcard,

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]

Jim

[edited by: jdMorgan at 7:26 pm (utc) on Nov. 4, 2007]

smartcard

4:20 pm on Nov 5, 2007 (gmt 0)

10+ Year Member



Thanks jdMorgan,

It works fine.