[英]URL Rewriting not working (ubuntu13.10/apache2.4.6)
I need your help! 我需要你的帮助! (sorry for my bad english) (对不起,我的英语不好)
I try to do url rewriting in my localhost on Ubuntu13.10/Apache2.4.6 ... I searched a lot of time on internet and problem is always here.. 我尝试在Ubuntu13.10 / Apache2.4.6上的本地主机中进行URL重写...我在互联网上搜索了很多时间,问题始终在这里。
this is my .htaccess (I begin in url rewriting so I don't know if it's ok) : 这是我的.htaccess(我从URL重写开始,所以我不知道是否可以):
RewriteEngine On
AllowFromAll All
RewriteRule home/ index.php?uc=home
and when I go to 127.0.0.1/mywebsite/home/
I have a 404 error. 当我转到127.0.0.1/mywebsite/home/
,出现404错误。
Please, I don't know what to do... 拜托,我不知道该怎么办...
After many tests : I think I have a problem of AllowOverride 经过多次测试:我认为我遇到了AllowOverride问题
You either need to specify the RewriteBase
您要么需要指定RewriteBase
RewriteBase /mywebsite/
RewriteRule home index.php?uc=home [L]
or add it to your rule 或将其添加到您的规则中
RewriteRule /mywebsite/home index.php?uc=home [L]
I think this is more like this : 我认为这更像是这样:
RewriteRule is relative to the RewriteBase, so if your .htacess is in /mywebsite/ folder : RewriteRule是相对于RewriteBase的,因此,如果您的.htacess位于/ mywebsite /文件夹中:
RewriteBase /
RewriteRule /home index.php?uc=home [L]
this way it should work, let me know ;) 这样就可以了,让我知道;)
So... If this is not working, let's start by the beginning. 所以...如果这不起作用,让我们从头开始。
LoadModule rewrite_module libexec/mod_rewrite.so
and AddModule mod_rewrite.c
should be in there, and without comment mark (#) 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]
This configuration works on my apache 2.2.22. 此配置适用于我的Apache 2.2.22。
The truth is that 事实是
/index.php?uc=home [L]
points on http://127.0.0.1/index.php
指向http://127.0.0.1/index.php
instead of http://127.0.0.1/mywebsite/index.php
而不是http://127.0.0.1/mywebsite/index.php
because of the DocumentRoot
property. 由于DocumentRoot
属性。 On a real domain, or /wa virtualhost pointing on /mywebsite/, /index.php?uc=home [L]
should work. 在真实域中,或/ wa virtualhost指向/index.php?uc=home [L]
应该可以工作。
Keep in mind that RewriteRule is relative to the DocumentRoot
and RewriteBase
can't resolves this problem. 请记住,RewriteRule是相对于DocumentRoot
而RewriteBase
无法解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.