ht访问不起作用找不到文件


htaccess not working cant find file

RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^Download/(.*)/?$ ./downloadit.php?key=$1 
RewriteRule ^Buy/(.*)/?$ ./buy.php?key=$1
RewriteRule ^Admin/(.*)/?$ ./admin.php?cmd=$1&key=$2
RewriteRule ^Admin/Edit/(.*)/?$ ./editfile.php?key=$1

我通常不使用阿帕奇重写引擎,所以我不确定。

我尝试解析的链接是:http://Website.com/~User/Download/Testlicious/

我总共有 4 个文件,都是 php 文件。我想直接重写到这些文件

但它一直给我一个 404 找不到/downloadit.php它在同一个目录中,与其他目录相同。

*更新***自从在虚拟主机上,嘟嘟。我需要正确设置我的重写基础,DOH

RewriteEngine On
RewriteBase /~GameCenter/
RewriteRule ^Download/(.*)/?$ ./downloadit.php?key=$1 [qsa]
RewriteRule ^Buy/(.*)/?$ /buy.php?key=$1
RewriteRule ^Admin/(.*)/?$ /admin.php?cmd=$1&key=$2
RewriteRule ^Admin/Edit/(.*)/?$ /editfile.php?key=$1 

现在一切都链接和工作,但现在的问题是 $0/$1/$2 不会触发文件中的任何内容。没有什么吐出 $_POST['钥匙']

现在我想问题的第 1 步已经解决了。但现在进入第 2 步O_O!!

您需要

为每个规则添加条件,而且我很确定RewriteRule模式匹配在开始时也需要斜杠

我假设 4 个 PHP 文件与您的.htaccess文件位于同一目录中。

[L]告诉mod_rewrite停止解析当前请求的.htaccess文件:

RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^Download/(.*)/?$ /downloadit.php?key=$1 [L]
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^Buy/(.*)/?$ /buy.php?key=$1 [L]
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
# You've only specified one matching group here, so $2 will be blank
RewriteRule ^Admin/(.*)/?$ /admin.php?cmd=$1&key=$2 [L]
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^Admin/Edit/(.*)/?$ /editfile.php?key=$1 [L]