重写规则访问混乱



所以我是htaccess中ReWrite规则的新手,可能需要的帮助

我目前有一个php页面poll.php基本模板,用于它从PHPMyAdmin获得的信息。通过pollcode获得轮询的信息。在这个例子中,它将是vmxez,所以poll.php?code=vmxez正确地显示了我想要的方式,但我正在尝试重写它,所以domain.com/vmxez显示了domain.com/poll.php上的内容?code=vmxez任何帮助都将是伟大的战斗2小时。

假设重写模块已安装并启用,

# Turn on the rewrite engine
RewriteEngine On
# Set the base path
RewriteBase /
# Rewrite an exact match of /vmxez
RewriteRule ^/vmxez$ /poll.php?code=vmxez

如果您的目标实际上是将所有非PHP脚本请求发送到poll.hp:

# Skip rewrites for direct file requests (e.g. PHP scripts)
RewriteCond %{REQUEST_FILENAME} !-f
# Capture the path requested and pass it as a parameter
RewriteRule ^(.+)$ /poll.php?code=$1

最新更新