Results 1 to 3 of 3

Thread: URLs with no IDs in Php

  1. #1
    Szise is offline Net Builder
    Join Date
    Dec 2008
    Posts
    426
    Thanks
    14
    Thanked 33 Times in 29 Posts

    URLs with no IDs in Php

    I have a piece of code and i'm trying to modify it to list the URLs more seo friendly.

    Currently the URLs are displayed like this :

    /view/3456/keyword.html , is posible to display the URLs as /view/keyword.html without the ID number ?

    PHP Code:
    <?

    $sql 
    mysql_query("SELECT * FROM my_data WHERE published=1 ORDER BY id desc LIMIT 10");
        while(
    $row mysql_fetch_array($sql))
        {
            
    $abcd$row['name'];
            
    $abcd str_replace (" ""-"$abcd);
                
                if (
    $seo_on == 0
                {
                    
    $url 'index.php?task=view&id='.$row['id'].'';
                }
                else 
                {
                    
    $url 'view/'.$row['id'].'/'.$abcd.'.html';
                }
            
            echo 
    '&nbsp;<a href="'.$site_url.'/'.$url.'">'.$row['name'].'</a><br>';
        }
    ?>
    Or i need to modify something else to make it work because if i type www.domain/view/keyword.html i see page not found.
    ...

  2. #2
    AstroNyu is offline Newbie Net Builder
    Join Date
    Jan 2009
    Posts
    117
    Thanks
    5
    Thanked 13 Times in 11 Posts
    http://www.domain.com/index.php?task=view&id=2345

    In htaccess:
    PHP Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule 
    (.*)-(.*)\.html$ /index.php?task=$1&id=$
    result: http://www.domain.com/view-2345.html



    Just noticed that you mean editing your given code:
    Try this,
    PHP Code:
     <?

    $sql 
    mysql_query("SELECT * FROM my_data WHERE published=1 ORDER BY id desc LIMIT 10");
        while(
    $row mysql_fetch_array($sql))
        {
            
    $abcd$row['name'];
            
    $abcd str_replace (" ""-"$abcd);
                
                if (
    $seo_on == 0
                {
                    
    $url 'index.php?task=view&id='.$row['id'].'';
                }
                else 
                {
                    
    $url 'view/'.$abcd.'.html';
                }
            
            echo 
    '&nbsp;<a href="'.$site_url.'/'.$url.'">'.$row['name'].'</a><br>';
        }
    ?>
    Multiple File Mirror | Free Public Rapidleech Server

    ElevatedServers.net - starting from $3.99/mo
    30 days moneyback guarantee | 99.9% uptime SLA | 24/7 Support

  3. Thanked by:

    Will.Spencer (30 April, 2009)

  4. #3
    Szise is offline Net Builder
    Join Date
    Dec 2008
    Posts
    426
    Thanks
    14
    Thanked 33 Times in 29 Posts
    The page is pointing to the main page but is a good sign anyway, better than not found.
    ...

Similar Threads

  1. Replies: 0
    Last Post: 11 November, 2009, 10:21 AM
  2. Question about Digg URLs
    By Jesse in forum Social Bookmarking
    Replies: 1
    Last Post: 22 July, 2009, 12:10 PM
  3. Tool to optimize your URLs
    By Micks86 in forum Promoting
    Replies: 1
    Last Post: 7 June, 2009, 19:54 PM
  4. How to mask urls?
    By nick09 in forum Web Design
    Replies: 0
    Last Post: 1 June, 2009, 11:09 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •