Jump to content

How To make SEO Friendly URL


logicslab

Recommended Posts

Hi Friends , My need I depicted Below.... Please Help me how it can possible.

 

 

Explanation by Example :

 

Suppose, there is one website url :

www.sitename.com/article.php?id=5

 

I can convert the URL in SEO friendly manner with rewrite rule in

.htaccess file as below :

www.sitename.com/article/5 [i CAN DO THIS]

 

But what I want is, The name of the Article in the URL like :

www.sitename.com/article/the_name_of_the_article_here [i WANT THIS]

 

I tried lot for the solution of this problem but didn't got any.

Please tell me if you can suggest any tip.

 

You can contact me : [email protected]

 

I am waiting for your Good help

 

Regards

Anes

Link to comment
https://forums.phpfreaks.com/topic/201918-how-to-make-seo-friendly-url/
Share on other sites

Have you tried doing some like:

 

Example: article.php:

 

The withdrawl of the code bellow is that you would have to in some way be able to show your current database rows that hold the information such as the title that will be used as a link. - By this I mean you would have to have a page where news rows where added when new news is created - Easily done but that is your choice.

 

 

<?

$title = $_GET[article];

includes("config-file-directory.php");

$query = mysql_query("SELECT * FROM newscatagory WHERE title = '$title' LIMIT 1 order by id DESC") or die(mysql_error());

$row = mysql_fetch_array($query);

 

if($title =='$row[title]'){ ?>

 

<? echo"$row[title]"; ?><br>

<? echo"$row[article]"; ?><br>

<? echo"$row[reporter]"; ?><br>

<!-- examples of table row/column names --!>

<? } ?>

 

So if the database had a row that had an article with the title:

 

and I went and typed the following link:

http://www.somesite.com/article.php?article=peter_pan_becomes_a_man

 

Then it would distribute the example rows Title, Article and reporter for the row with the identical title in the database to that in the URL

 

As for MOD_Rewrite (Not huge expert on but)

 

.htaccess

 

<IfModule mod_rewrite.c>

  RewriteEngine on

RewriteRule ^articles/(.*)$ article.php?article=$1

</IfModule>

 

Something along those lines not set in stone although I hope it helped :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.