-1

我想制作一个用于检查 colorhex 代码的 php 网站,现在我在检查代码时遇到了一个问题,我的脚本是

<?php
echo'
<html><head><style>
body{
background-color:#'.$_GET['c'].';
}
</style></head><body></body></html>';
?>

我输入 urlhttp://example.com/?c=FF0000 会将背景颜色显示为红色,但我想隐藏 ?c= 并修改 htaccess 文件,我已经用谷歌搜索并尝试过但没有人工作,有人知道该怎么做吗?

4

1 回答 1

1

Something like this in the server configuration or a .htaccess file:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]{6})$ index.php?c=$1 [L]

If you run into problems with rewriting it always is a very good idea to use the loggin facility apaches rewriting module brings along. Read the manual about the two configuration options RewriteLog and RewriteLogLevel, they give you a wealth of additional information that helps to understand what is actually going on during the rewrite.

于 2012-10-21T11:07:19.087 回答