【问题标题】:.htaccess - Convert PHP GET to URL Path but keep GET in URL.htaccess - 将 PHP GET 转换为 URL 路径,但将 GET 保留在 URL 中
【发布时间】:2014-06-04 21:15:13
【问题描述】:

我的目标是将 http://example.com/c/themeforest/wordpress 之类的 URL 重定向到 PHP http://example.com/?params=c/themeforest/wordpress

为此,我使用了一个包含以下内容的 .htaccess 文件:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?params=$1 [NC]

但现在我还必须能够重定向像 http://example.com/c/themeforest/wordpress?p=2 这样的 URL 多个页面发送至http://example.com/?params=c/themeforest/wordpress&p=2

页码必须在单独的 PHP GET 变量中发送。

【问题讨论】:

    标签: php .htaccess get


    【解决方案1】:

    添加 QSA(查询字符串附加)标志,所以:

    RewriteRule ^(.*)$ index.php?params=$1 [NC,QSA]
    

    【讨论】:

      猜你喜欢
      • 2011-05-03
      • 1970-01-01
      • 2012-04-02
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 2012-01-27
      • 2016-12-21
      相关资源
      最近更新 更多