how to simplify the url

前端 未结 1 349
盖世英雄少女心
盖世英雄少女心 2021-01-28 01:39

Hi: In my website I found that their url are very simple like:

http://example.com/questions/4486620/randomaccessfile-probelm

And generally the url should like:

相关标签:
1条回答
  • 2021-01-28 01:48

    On an apache web server you can do this using mod_rewrite http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

    Here is an example along with a tutorial...

    The Apache rewrite engine is mainly used to turn dynamic url’s such as www.yoursite.com/product.php?id=123 into static and user friendly url’s such as www.yoursite.com/product/123

    Read more about htaccess And mod_rewrite Tutorial by Blogstorm SEO Blog

    RewriteEngine on
    RewriteRule ^product/([^/\.]+)/?$ product.php?id=$1 [L]
    Another example, rewrite from:
    www.yoursite.com/script.php?product=123 to www.yoursite.com/cat/product/123/
    
    RewriteRule cat/(.*)/(.*)/$ /script.php?$1=$2
    

    Read more here that example by the way is copied from http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/ - assigned kudos!

    0 讨论(0)
提交回复
热议问题