doulipi3742 2012-06-21 06:07
浏览 43
已采纳

如何在地址栏中隐藏GET变量[重复]

Possible Duplicate:
How to change appearance of URL from within a PHP script

I have this in my address bar

localhost/somedirectory/main.php?id=123456

how to hide those GET variables, so it becomes

localhost/somedirectory/main/123456

I know .htaccess is the answer but my attempts so far are to no avail. Could someone please shed some light on how to achieve it?

  • 写回答

1条回答 默认 最新

  • doufu7835 2012-06-21 06:10
    关注

    No way to do it with PHP the way you want!

    Only htaccess will help for this task.

    RewriteEngine on 
    RewriteBase    /
    RewriteRule ^localhost/([^/]*)/([^/]*)/([^/]*)$    localhost/$1/$2.php?id=$3
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?