Apache 2 - Mod 重写已安装并处于活动状态,但我无法让它工作......我做错了什么?
据我所知,Mod Rewrite 已激活并启用(我按照教程安装它并使用 a2enmod rewrite 激活它)。
我正在尝试使用 PHP 设置一些漂亮的 URL - 我非常想要:
mysite.com/sites/mysite/blog/article-title-here/
而不是 mysite.com/sites/mysite/blog/index.php?article =文章标题-这里
我正在关注 Nettuts 教程在这里。 (无论如何使用 PHP 部分)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
我什至查看了一些具有类似标题的问题,并尝试遵循它们的解决方案,但我仍然得到标准的 404。
我对整个服务器管理方面还很陌生,并且正在通过低成本裸 VPS 尽可能多地学习。这很有挑战性,也很有趣,但这让我抓狂。
Mod Rewrite is activated an enabled as far as I can tell (I followed the tutorial to install it and activate it using a2enmod rewrite).
I'm trying to set up some pretty URLS using PHP - prettymuch I want:
mysite.com/sites/mysite/blog/article-title-here/
instead of mysite.com/sites/mysite/blog/index.php?article=article-title-here
I'm following Nettuts tutorial here to the letter. (the Using PHP portion anyway)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
I've even looked at some of the Questions with similar titles and tried following the solutions for them as well, but I just get the standard 404 still.
I'm pretty new to the whole server admin thing and am learning as much as I can through a low cost naked VPS. It's challenging and fun, but this has me pulling my hair out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果可能的话,您应该使用 Apache 部分而不是 PHP。
Mod 重写是那些比表面上看到的要复杂得多的代码之一,在编码时值得查看一些教程/示例/参考,以确保您没有错过您的重要内容用法。
该代码基于您的问题的最低要求,这些恰好是我对其实施的网站的最低要求,如果还有其他变量,您可能需要调整它以适应。例如,需要添加 URL 字符串中的其他变量并更改路径。
这是另一个参考这可能对你有帮助。
我希望这有帮助:-)
You should use the Apache section rather than PHP if possible.
Mod rewrite is one of those bits of code that is much more complex than would be seen at face value to it is worth looking at a few tutorials/examples/references when coding it to make sure that you haven't missed something important under your usage.
This code is based on minimum requirements based on your question, these happen to be my minimum requirements for the site I have implemented it for and if there are other variables you may need to adjust it to suit. E.g. other variables in the URL string will need to be added and changing the path.
Here is another reference that may help you.
I hope this helps :-)