Problem to create SEARCH ENGINE FRIENDLY URL / URL Rewrite using RewriteRule

Discussion in 'PHP' started by php_freelancer, Oct 30, 2007.

  1. #1
    Some problem on URL Rewrite using RewriteRule

    When somebody uses this in a page then all hyperlinks in that page is rewritten in sub-directory format, which the webmaster hardly wants

    As for example - www.abc.com/file.php has a hyperlink in it as home page (<a href='index.php'>Home Page</a>) which points index.php page of www.abc.com, that is absolute URL www.abc.com/index.php . index.php and file.php is in same directory of website www.abc.com

    Now, say,

    www.abc.com/file.php?varname=value is rewritten in search engine friendly way
    www.abc.com/file/varname/value/

    When this search engine friendly URL is typed in a browser, the same page opens which is file.php, but the links in that page are changed

    Then the Home Page hyperlink now points to /file/varname/value/index.php , that is hyperlink changes to <a href='/file/varname/value/index.php'>Home Page</a> - absolute path is www.abc.com/file/varname/value/index.php, which don't exists in reality.

    But the hyperlink should point to www.abc.com/index.php

    Have u faced this problem ??

    .htaccess file content
    ------------------------

    RewriteEngine On
    RewriteBase /
    RewriteRule ^file/varname/value/ file.php?varname=value
     
    php_freelancer, Oct 30, 2007 IP
  2. php_freelancer

    php_freelancer Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    See the demo of the above problem here : See a demo of the problem stated above here

    http://demo.rankingoogle.com/seo_url/
     
    php_freelancer, Oct 30, 2007 IP
  3. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Place the following code in the <head> section of your page

    <base href="http://www.abc.com/" />

    This will become the root path for any relative URLs on your page.

    Hope this helps :)
     
    tonybogs, Oct 31, 2007 IP