[英]Mod_Rewrite rule ignored on Server
i got the following RewriteRule in my .htaccess
-file: 我在
.htaccess
文件中得到以下RewriteRule:
RewriteRule ^([a-z]+)/(.*)$ distributor.php?file=$1¶ms=$2 [L]
If i request for example " www.domain.local/index/id/123
" on my local system via Xampp this works perfectly. 如果我通过Xampp在本地系统上请求例如“
www.domain.local/index/id/123
”,则此方法非常有效。 It requests distributor.php (which does a simple var_dump($_GET);
) and results in the expected output: 它请求distributor.php(它执行一个简单的
var_dump($_GET);
)并产生预期的输出:
array
'file' => string 'index' (length=5)
'params' => string 'id/123' (length=6)
When uploading these files to the server, the rule does not apply. 将这些文件上传到服务器时,该规则不适用。 The browser simply outputs the DirectoryIndex file.
浏览器仅输出DirectoryIndex文件。
I am confused after hours of trying to fix it and would be thankful for any kind of help 经过数小时的尝试后,我感到困惑,感谢您提供的任何帮助
Thanks 谢谢
Update: 更新:
if i replace the slash by a dash and use the following rule: 如果我用破折号代替斜线并使用以下规则:
RewriteRule ^([a-z]+)-(.*)$ distributor.php?file=$1¶ms=$2 [L]
the whole thing works both on my local system and on the server. 整个事情在我的本地系统和服务器上均有效。
Is there anything i need to change to use the slash on the server as well? 我还需要更改以在服务器上使用斜杠吗?
Locate your apache configuration file and then add these lines : 找到您的apache配置文件,然后添加以下行:
<Directory /path/to/your/web/application>
Options Indexes FollowSymlinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
and then if the following line does not exist, write it : 然后,如果以下行不存在,则将其写入:
AccessFileName .htaccess
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.