Need htaccess file help

Discussion in 'PHP' started by webmaster365, May 2, 2011.

  1. #1
    Hello All,

    I am facing an issue, as have a website which runs normally no SEO friendly url.
    But I need a URL in SEO style so , how can i write the .htaccess file.

    Example below :

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^localhost.com [NC]
    RewriteRule ^(.*)$ http://www.localhost.com/user/$1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

    RewriteRule ^profile-user/(.*)/(.*)$ profile-user.php?uname=$1&id=$2

    So, the URL looks like as below.
    http://localhost/user/profile-user/apple/11

    Now the issue is as the URL works fine but other URL stop working as throwing error.

    Please help in this , Thanks in Advance.

    Please Note : I want only a single URL seo friendly other need as normal as below.

    http://localhost/user/profile?id=11
     
    webmaster365, May 2, 2011 IP
  2. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #2
    What development environment you use? If you are using apache under windows, it is not possible I think. You need a rewrite apache module.
     
    MayurGondaliya, May 2, 2011 IP
  3. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #3
    what is the error you got on the other pages?
     
    salmanshafiq, May 2, 2011 IP
  4. Projekt.Gopher

    Projekt.Gopher Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If both pages return the same result, and you're worried about duplicate content, you could also set up a simple 301 redirect in the first couple lines of your php file, or even just use a canonical link in your html documents <head>
     
    Projekt.Gopher, May 3, 2011 IP
  5. webmaster365

    webmaster365 Greenhorn

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    Hello All,

    Thanks for your reply as I got the solution.
     
    webmaster365, May 3, 2011 IP