.htaccess使用URL参数从一个文件重写到另一个文件

时间:2014-05-24 06:53:33

标签: apache .htaccess

我一直在寻找这个,但.htaccess语法仍然是一种神秘的语言,我最终做了大量的猜测和检查。

我试图重写请求:

/folder/index.php?id = ... - > /folder/index-new.php?id = ...

我可以替换index.php,原因不值得解释。我希望每次请求index.php时都使用参数重定向到index-new.php。

1 个答案:

答案 0 :(得分:0)

将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteRule ^(folder)/index\.php$ /$1/index-new.php [L,NC]

QUERY_STRRING会自动转移到新网址。