干净 URL 上的 PHP 问号
我目前正在尝试了解干净的网址。我曾经使用过Windows。 我切换到 ubuntu 时突然我的 .htaccess 似乎无法工作 这是我的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
所以我有这个网址
我期待它说“my_name”浏览器中的字符串
hello my_name
但只有当我添加“?”时它才会起作用在 URI 中
我很确定 mod_rewrite 已启用。我什至检查了我的 phpinfo()
i am currently trying to learn about clean urls. i was using windows once.
i switched to ubuntu when suddenly my .htaccess seems to be not working
here is my htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
so i have this url
i was expecting it to say the 'my_name' string in the browser
hello my_name
but it would only work whenever i add a '?' in the uri
i am pretty sure mod_rewrite is enabled. i even checked my phpinfo()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来重写模块被禁用了。编辑您的 apache 配置并加载
mod_rewrite
的动态模块(如果可用)。它看起来像这样:如果您使用的是 Ubuntu,请运行 sudo a2enmod rewrite 来通过重新启动 Apache 服务器来启用以下模块:
It sounds like the rewrite module is disabled. Edit your apache configuration and load the dynamic module for
mod_rewrite
if available. It would look like this:If you're using Ubuntu, run
sudo a2enmod rewrite
to enable the module following by restarting the Apache server:找到了解决方案。转储 $_SERVER 变量并使用 REQUEST_URI 索引,因为 QUERY_STRING 不显示任何内容。会+1 Lekensteyn的答案,因为它引导我走上了正确的道路
Found a solution. dumped the $_SERVER variable and used the REQUEST_URI index since QUERY_STRING does not display anything. will +1 Lekensteyn's answer since it led me to the right path