dsbj66959 2011-10-29 13:31
浏览 13
已采纳

如何更改网站网址的结构?

Web sites that designed with a framework, there isnt "/" at end of their address How Can I create like these sites only with php and hide ".php" from end of my addresses?

example: www.mydomain.com/page/1 -> this means that the user should see the page 1 but in my server root there isnt any folder with name "page"

sorry for my bad english:(

  • 写回答

2条回答 默认 最新

  • duan97689 2011-10-29 13:35
    关注

    One way to do it, is using URL rewrite support of Apache. For example, if you've a webpage called show.php?id=numeric-id you can map it to /show/numeric-id with the following rule:

    RewriteEngine on
    RewriteRule ^/show/([0-9]+)$ /show.php?id=$1
    

    This configuration can be put in Apache Virtualhost configuration or in a .htaccess file, provided that the permissions FileInfo and Options of AllowOverride are activated. To activate them, add a line like this in Apache configuration:

    AllowOverride FileInfo Options
    

    Alternatively, All activates all permissions:

    AllowOverride All
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?