[英]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.