Forum Moderators: coopster

Message Too Old, No Replies

Re-write URLs SEO friendly - Urgent

Re-write URLs SEO friendly

         

sandykadam

9:11 am on Mar 31, 2008 (gmt 0)

10+ Year Member



Hi Friends,

I want to create SEO friendly URLs in PHP. I know that we can do from .htaccess file but other than that do we have to make some different php script also?

Following is my files:

index.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<a href="newsdetails.php?nid=1">News 1</a><br>
<a href="newsdetails.php?nid=2">News 2</a>
</body>
</html>

newsdetails.php

<?php
echo "<br> in news";
?>

.htaccess file
# //seo_mod_start
Options +Indexes +FollowSymlinks
RewriteEngine On
# Uncomment the following and add your forum path if rewrites arent working properly
RewriteRule ^index.html$ index.php [L,NE]
RewriteRule ^(.*)-a-([0-9]+).html$ newsdetails.php?nid=$2 [L]
# //seo_mod_end

But when i view index.php in browser its not showing seo friendly urls of news it shud take title of news to display.

Can anybody please help me.

eelixduppy

10:45 pm on Apr 7, 2008 (gmt 0)



You must change the code in your HTML to follow your new friendly URI scheme. something like the following:

<a href="1.html">News 1</a><br>
<a href="2.html">News 2</a>

You are doing a rewrite not a redirect so going to the original url won't change anything.

sandykadam

6:42 am on Apr 11, 2008 (gmt 0)

10+ Year Member



Ok.. you mean to say that I will have to give seo friendly url names.
For eg:

Orkut is best social networking site.
Google best search engine

So I need output as below:

orkut-is-best-social-networking-site.php OR .html
google-best-search-engine.php OR .html

htaccess will not take title dynamically ? or I will have to manipulate those names and give urls?

Marcia

7:07 am on Apr 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll have to do links to the seo-friendly page URLs in the HTML on the site.