我该如何为此配置.htaccess文件?

时间:2012-05-27 11:28:19

标签: php .htaccess

我的链接如下(index.php):

<a href="http://localhost/example-link.html">Example Link</a>

或者我的链接如下:

<a href="http://localhost/other.html">Other</a>

点击链接后我想从 cat.php

获取“example-link.html”ır“other.html”

Cat.php

<?php 
echo $_GET["cat"];
?>

我想打印$ _GET [“cat”](example-link.html或other.html)

2 个答案:

答案 0 :(得分:1)

RewriteEngine On
RewriteRule ^(.+)\.html$ cat\.php 
  

我想打印$ _GET [“cat”](example-link.html或other.html)

预定义变量$_SERVER将包含部分信息,可能是REQUEST_URI

答案 1 :(得分:0)

# Redirect old file path to new file path
Redirect /example-link.html http://localhost/cat.php