[英].htaccess url rewriting scheme not working in the server. in localhost it works
我已經在koding.com VPS中安裝了php 5.59和apach2 2.4.7。 我有一個有效的.htaccess文件,該文件(目前還不太干凈)在本地運行,沒有任何問題。 但是,當我將網站上傳到服務器時,它的運行方式卻很有趣。 有一個這樣的網址
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
使用SSH連接到服務器
$ sudo a2enmod rewrite
$ sudo service apache2 restart
似乎您的服務器上未啟用重寫mod(但在本地計算機上)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.