SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making SEO friendly URL...using .htaccess file....Need Help.

    Hi,

    I am making an SEO friendly URL so that I can hide the parameters form the visitors. I am using .htaccess files to redirect it.

    Its working fine when I created it to view profiles...where I call database...

    But When I used it to search results Form $_POST Method....it flagging up with the result URL not Found.

    .htaccess file Contains this:
    RewriteEngine On

    RewriteRule ^([a-zA-Z0-9-/]+).html$ profile.php?url=$1
    RewriteRule ^([a-zA-Z0-9-/]+).html/$ profile.php?url=$1

    This is how I am redirecting....
    PHP Code:
    $blog='';
                                    
    $caste $_POST['religon'];
                                    
    $loginID $_POST['gender'];
                                if(
    $_SERVER["REQUEST_METHOD"] == "POST")
                                {
                                    
    $title=mysql_real_escape_string($loginID);
                                    
    $body=mysql_real_escape_string('');
                                    
    $title=htmlentities($title);
                                    
    $body=htmlentities($body);
                                    
    $date=$caste;
                                    
                                    
    $newtitle=string_limit_words($title6);
                                    
    $urltitle=preg_replace('/[^a-z0-9]/i',' '$newtitle);
                                    
                                    
    $newurltitle=str_replace(" ","-",$newtitle);
                                    
    $url=keyword/'.$date.'/'.$newurltitle.'.html';
                                    
                                    $blogurl="http://localhost/website/$url";
                                    mysql_query("insert into blog(title,body,url) values('
    $title','$body','$url')");
                                    //header("Location: $blogurl");
                                    echo "<a style=\"color:#1591d2;\" href=\"$blogurl\">View Profile</a>";

    Please let me know if I mistook somewhere..

    Your help would be appreciated.

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hy,
    In your code it's missing a quote at the seting of $url, correct:
    PHP Code:
    $url='keyword/'.$date.'/'.$newurltitle.'.html'
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners


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
  •