【问题标题】:.htaccess query string to folder format.htaccess 查询字符串到文件夹格式
【发布时间】:2011-09-24 01:03:22
【问题描述】:

我有一个带有查询字符串的查询 URL,我想将其转换为文件夹结构的 URL。

例如:

http://localhost/index.php?page=about-us
http://localhost/index.php?page=contact-us

我会怎样把它转换成

http://localhost/index/page/about-us
http://localhost/page/about-us

我知道这可以通过 .htaccess 来完成。我只是不知道从哪里开始

【问题讨论】:

标签: .htaccess query-string directory-structure


【解决方案1】:

你需要一些类似...的东西

Options +FollowSymLinks   
RewriteEngine On   

RewriteCond %{SCRIPT_FILENAME} !-d   
RewriteCond %{SCRIPT_FILENAME} !-f   

RewriteRule ^page/([-a-z-0-9]+)*/$ ./index.php?page=$1
RewriteRule ^index/page/([-a-z-0-9]+)*/$ ./index.php?page=$1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 2012-11-24
    • 2022-01-12
    • 1970-01-01
    相关资源
    最近更新 更多