[英]LAMP stack's PHP not working (Ubuntu 13.10 / Apache 2.4.6)
[英]URL Rewriting not working (ubuntu13.10/apache2.4.6)
我需要你的幫助! (對不起,我的英語不好)
我嘗試在Ubuntu13.10 / Apache2.4.6上的本地主機中進行URL重寫...我在互聯網上搜索了很多時間,問題始終在這里。
這是我的.htaccess(我從URL重寫開始,所以我不知道是否可以):
RewriteEngine On
AllowFromAll All
RewriteRule home/ index.php?uc=home
當我轉到127.0.0.1/mywebsite/home/
,出現404錯誤。
拜托,我不知道該怎么辦...
經過多次測試:我認為我遇到了AllowOverride問題
您要么需要指定RewriteBase
RewriteBase /mywebsite/
RewriteRule home index.php?uc=home [L]
或將其添加到您的規則中
RewriteRule /mywebsite/home index.php?uc=home [L]
我認為這更像是這樣:
RewriteRule是相對於RewriteBase的,因此,如果您的.htacess位於/ mywebsite /文件夾中:
RewriteBase /
RewriteRule /home index.php?uc=home [L]
這樣就可以了,讓我知道;)
所以...如果這不起作用,讓我們從頭開始。
LoadModule rewrite_module libexec/mod_rewrite.so
和AddModule mod_rewrite.c
應該在其中,並且不帶注釋標記(#)
# The server must follow symbolic links (this can help in some apache versions)
Options +FollowSymlinks
# RewriteEngine activation
RewriteEngine on
# RewriteRule
RewriteRule ^home$ index.php?uc=home [L]
此配置適用於我的Apache 2.2.22。
事實是
/index.php?uc=home [L]
指向http://127.0.0.1/index.php
而不是http://127.0.0.1/mywebsite/index.php
由於DocumentRoot
屬性。 在真實域中,或/ wa virtualhost指向/index.php?uc=home [L]
應該可以工作。
請記住,RewriteRule是相對於DocumentRoot
而RewriteBase
無法解決此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.