我已经在我的koding.com VPS中安装了php 5.59和apach2 2.4.7。我有一个工作的.htaccess文件,它(目前不是很干净)在本地运行,没有任何问题。无论如何,当我将网站上传到服务器时,它的工作方式很奇怪。有一个URL是这样的
http://bhashithe.koding.io/forum/read/need-to-check-the-answer-counter-works我添加了这样的重写方案
RewriteRule ^read/(.*)$ /read.php?url=$1但当我打开那个链接时,它被重定向到这个
http://bhashithe.koding.io/forum/read.php?url=need-to-check-the-answer-counter-works无论这个链接是如何工作的,都很好。但当我打开其他链接时,那些返回404错误的链接完全重定向到了我在.htaccess文件中提到的那个链接。
我包含了整个文件供您参考。
RewriteEngine on RewriteCond %{HTTP_HOST} ^bhashithe.koding.io [NC]
RewriteRule ^read/(.*)$ /read.php?url=$1
RewriteRule ^edit/(.*)$ /creator.php?url=$1
RewriteRule ^category/(.*)$ ./category.php?category=$1
RewriteRule ^tag/(.*)$ ./tag.php?tag=$1
RewriteRule ^index.html$ ./post.php
RewriteRule ^$ ./post.php
RewriteRule ^login$ ./login.php
RewriteRule ^new/$ ./creator.php
RewriteRule ^search/(.*)$ ./search.php?key=$1
RewriteRule ^profile/(.*)$ ./profile.php?username=$1
RewriteRule ^login/(.*)$ ./login.php?response=$1
RewriteRule ^settings/(.*)$ ./settings.php?response=$1
RewriteRule ^profile/(.*)$ ./forum/profile.php?username=$1&feedback=$2
ErrorDocument 404 /forum/error.php如果我做错了什么,请您指出。谢谢,Bhashithe
发布于 2015-06-10 00:03:11
使用SSH连接到服务器
$ sudo a2enmod rewrite
$ sudo service apache2 restart您的重写模式似乎没有在您的服务器上启用(但在您的本地计算机上)。
https://stackoverflow.com/questions/30736820
复制相似问题