skip to Main Content

I am new to url rewrite . I have a completed site with urls like abc.com/abc.php?id=54&title=abcd. First of all i need friendly urls for SEO like abc.com/abc/54/abcd. I know that can b accomplish by redirecting urls in .htaccess (But i have to change all my urls in code too). can i accomplish that without changing all my code url. Second how to not disturb the assets.

Need Help .
Thanks

3

Answers


  1. You must change all your URLs in the code.. The other functionalities should not be affected as the .htaccess rewriting will point to the old URLs.

    You could find an workaround to redirect the user with javascript but this is not recommended for SEO. Something like:

    <a href="abc.php?id=54&title=abcd">abcd</a>
    

    JS (jQuery):

    $(document).ready(function(){
         $('a').click(function(e){
             e.preventDefault();
             // parse the url to get its components
             window.location = '/' + parsedURL.filename + '/' + parsedURL.queries['id'] + '/' + parsedURL.queries['title'];
         });
    });
    
    Login or Signup to reply.
  2. I know this will be a very controversial answer, but bear in mind… this is Googles answer to this question.

    For so many people, they believe (because they’ve been taught) that dynamic URLs like page.php?id=3&entry=65 are bad for SEO.

    However, that was before… and this is now.

    In fact, with the progress that has been made by search engine crawlers such as “googlebot”, the opposite is true.

    It is best to leave your dynamic URLs alone and not rewrite them (for SEO purposes).

    This excerpt is from Google Webmaster Central…

    Myth: “Dynamic URLs cannot be crawled.”
    Fact: We can crawl dynamic URLs and interpret the different parameters. We might have problems crawling and ranking your dynamic URLs if you try to make your urls look static and in the process hide parameters which offer the Googlebot valuable information. One recommendation is to avoid reformatting a dynamic URL to make it look static. It’s always advisable to use static content with static URLs as much as possible, but in cases where you decide to use dynamic content, you should give us the possibility to analyze your URL structure and not remove information by hiding parameters and making them look static.

    Does that mean I should avoid rewriting dynamic URLs at all?
    That’s our recommendation, unless your rewrites are limited to removing unnecessary parameters, or you are very diligent in removing all parameters that could cause problems. If you transform your dynamic URL to make it look static you should be aware that we might not be able to interpret the information correctly in all cases. If you want to serve a static equivalent of your site, you might want to consider transforming the underlying content by serving a replacement which is truly static. … However, if you’re using URL rewriting (rather than making a copy of the content) to produce static-looking URLs from a dynamic site, you could be doing harm rather than good.

    You can read the full article here

    I found this simply by searching the term “rewrite URL for dynamic pages”. (on yahoo… not Google)

    And this article by Barry Schwartz.

    Barry Schwartz is Search Engine Land’s News Editor and owns RustyBrick, a NY based web consulting firm. He also runs Search Engine Roundtable, a popular search blog on very advanced SEM topics.

    Login or Signup to reply.
  3. You can use this rule in your DOCUMENT_ROOT/.htaccess file:

    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^([w-]+)/([w-]+)/([w-]+)/?$ $1.php?id=$2&title=$3 [L,QSA]
    

    This will let you use abc.com/abc/54/abcd in browser and it will internally route to abc.com/abc.php?id=54&title=abcd.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search