.htaccess 不重写 url
我有这个问题: 服务器的管理员说他为 apache 服务器启用了 rewrite_module,但是当我将一些测试文件上传到服务器来测试此功能时,它不起作用。
我在本地主机上启用了它,并且它在那里工作得很好。
.htaccess 内容:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^games/(.*)$ games.php?id=$1 [L]
games.php 内容:
<?php
$var = $_GET['id'];
echo $var;
?>
URLS:
localhost url:http://localhost/testing/games/123123
production url:http://mysite.com/test2/games/123123
test2 是包含文件(.htaccess 和 games.php)的文件夹 在生产中发生的情况是,当我输入此内容时,我得到页面 games.php 但 id 没有得到回显,并且查询字符串为空,而不是得到我提供的 id 123123。对于 localhost,一切正常,我得到 id 回显。 也许管理员是错的还是什么?先感谢您。
I have this problem:
The administrator of the server says that he had rewrite_module enabled for the apache server but when I upload some test files to the server to test this functionality it does not work.
I have it enabled at localhost and it works perfectly fine there.
.htaccess content:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^games/(.*)$ games.php?id=$1 [L]
games.php content:
<?php
$var = $_GET['id'];
echo $var;
?>
URLS:
localhost url:http://localhost/testing/games/123123
production url:http://mysite.com/test2/games/123123
test2 is the folder that contains the files (.htaccess and games.php)
What happens in production is that when i type this i get the page games.php but the id does not get echoed and query string is empty instead of getting the id 123123 which I provided.For localhost everything works fine and I get the id echoed.
Maybe the administrator is wrong or what? Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您位于子目录中,并且告诉引擎在请求完全以“games”开头时进行重写。您可以尝试删除插入符号 ^,或将其替换为斜杠 / ... 或在 RewriteEngine on :
in production:
之后添加此内容,或者尝试:
You are in subdirectories and you're telling the engine to rewrite when the request begins exactly with 'games'. You can try to remove the caret ^, or replace it with a slash / ... or add this after RewriteEngine on :
in production:
Or try: