.htacces网址重写 [英] .htacces url rewriting
问题描述
我的用户目录下有一个php / apache网站,例如 http:// localhost /〜johnny5 /
I have a php/apache website under my userdir, say http://localhost/~johnny5/
我有一个 / en
文件夹,其中有一个 .htaccess
文件和一个 index.php
文件:
I have a /en
folder with a .htaccess
file and a index.php
file :
/home/johnny5/public_html
/somefile.php
/someotherfile.php
/en/
.htacces
index.php
我在 / en
下启用了URL重写,因此所有请求都由index.php处理。这是.htacces的内容:
I enable url rewriting under /en
so all the request are handled by index.php. here's the content of .htacces :
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~johnny5/en
RewriteRule . index.php
到目前为止,一切正常。
当我按下 http:// localhost /〜johnny5 / en / foo / bar
时,请求由处理/en/index.php
。
现在,出于测试目的,我将该站点移至 / var / www下
,因此我可以直接通过 http:// localhost /
对其进行访问。我调整 .htaccess
文件以删除用户文件夹:
Now, for testing purpose, I move the site under /var/www
so I can acces it directly by http://localhost/
. I adjust the .htaccess
file to remove the user folder:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /en
RewriteRule . index.php
我现在具有以下结构:
/var/www
/somefile.php
/someotherfile.php
/en/
.htacces
index.php
现在,如果我按 http:// localhost / en / foo / bar
,我希望请求由 /en/index.php
处理,但我得到的只是一个404未找到为 / en / foo / bar
。
Now, if I hit http://localhost/en/foo/bar
, I'd expect the request to be handled by /en/index.php
, but all I got is a 404 not found for /en/foo/bar
.
我缺少了什么?
推荐答案
这就是我所有的错误-配置错误。
So that was all my error - misconfiguration.
我在错误的文件夹下 AllowedOverride。
I "AllowedOverride" under the wrong folder.
这篇关于.htacces网址重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!