Php URL重写不起作用(ubuntu13.10/apache2.4.6)
我需要你的帮助!(对不起,我的英语不好) 我尝试在Ubuntu13.10/Apache2.4.6上的本地主机中重写url。。。 我在网上搜索了很多时间,问题总是在这里 这是我的.htaccess(我从url重写开始,所以我不知道是否可以): 当我转到Php URL重写不起作用(ubuntu13.10/apache2.4.6),php,apache,.htaccess,url-rewriting,Php,Apache,.htaccess,Url Rewriting,我需要你的帮助!(对不起,我的英语不好) 我尝试在Ubuntu13.10/Apache2.4.6上的本地主机中重写url。。。 我在网上搜索了很多时间,问题总是在这里 这是我的.htaccess(我从url重写开始,所以我不知道是否可以): 当我转到127.0.0.1/mywebsite/home/时,我有一个404错误 My.htaccess位于:mywebsite/.htaccess 我用“sudoa2enmod rewrite”激活了url重写,并重新启动了apache 我在apache
127.0.0.1/mywebsite/home/
时,我有一个404错误
- My.htaccess位于:mywebsite/.htaccess
- 我用“sudoa2enmod rewrite”激活了url重写,并重新启动了apache
- 我在apache日志中没有错误
- 我在/etc/apache2/sites available/default中读到解决方案,他说我必须将AllowOverride更改为On,但我没有/etc/apache2/sites available/default文件
- 我迷路了
经过多次测试:我认为我有一个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]
这样应该可以,让我知道;) 所以。。。如果这不起作用,让我们从头开始 查找httpd.conf
LoadModule rewrite_module libexec/mod_rewrite.so
和AddModule mod_rewrite.c
应该在那里,并且没有注释标记(#)
在.htaccess中,有:
此配置适用于我的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
属性。在一个真正的域上,或者/w指向/mywebsite/的虚拟主机上,/index.php?uc=home[L]
应该可以工作
请记住,RewriteRule与
DocumentRoot
相关,而RewriteBase
无法解决此问题。您的htaccess文件在哪里?在mywebsite/.htaccess中。请参阅此内容,谢谢您的快速回答!我试过了,但我总是遇到同样的问题:404错误:/。。。但是apache2.4.6/ubuntu中没有httpd.conf。。。所以我不能做你的建议…甚至在/home/[user name]/apache/conf/httpd.conf
?不,在/home/[user name]/中没有apache文件夹,对不起
RewriteBase /
RewriteRule /home index.php?uc=home [L]
# 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]