public_html中的.htaccess返回404页


.htaccess in public_html returns 404 page

我是.htaccess相关内容的新手,尽管我既不喜欢linux也不喜欢php开发。我犯了一个让人发疯的错误。

我有启用了rewrite和userdir模块的apache。我的mod_userdir.conf看起来像这个

<IfModule mod_userdir.c>
   UserDir disabled root
   <Directory /home/*/public_html>
      AllowOverride All
      Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
      <Limit GET POST OPTIONS PROPFIND>
         Require all granted
      </Limit>
      <LimitExcept GET POST OPTIONS PROPFIND>
         Require all denied
      </LimitExcept>
   </Directory>
</IfModule>

我正在$HOME/public_html/mywebsite中构建一个网页,在那里我有一个.htaccess,代码为

Options +FollowSymLinks 
RewriteEngine On
#RewriteRule ^images/ - [L]
#RewriteRule ^css/ - [L]
#RewriteRule ^js/ - [L]
RewriteRule ^favicon.ico - [L]
RewriteRule ^(images|css|js|classes)($|/) - [L]
RewriteRule ^PayPal classes/paypal/initPP.php [L,QSA]
RewriteRule ^PDF MakePDF.php [L,QSA]
RewriteRule ^([-_0-9a-zA-Z:/]*)$ index.php?PageCall=$1 [L,QSA]
# 400 - Bad request
ErrorDocument 400 /index.php?error=400
# 401 - Authorization Required
ErrorDocument 401 /index.php?error=401
# 403 - Forbidden
ErrorDocument 403 /index.php?error=403
# 404 - Wrong page
ErrorDocument 404 /index.php?error=404
# 500 - Internal Server Error
ErrorDocument 500 /index.php?error=500

我的问题是每个访问http://localhost/~user/mywebsite返回404页面。我猜这是一个重写问题,因为当评论

RewriteRule ^([-_0-9a-zA-Z:/]*)$ index.php?PageCall=$1 [L,QSA]

该页面显示了与$_GET变量相关的php错误。

我做错了什么?。

提前谢谢。

编辑:我自己回答。似乎AllowOverride-On也必须写入httpd.conf中。所以我找

# forbid access to the entire filesystem by default
<Directory />
    Options None
    AllowOverride None
    Require all denied
</Directory>

并将AllowOverride更改为"All"。

当你在子目录中工作时,你必须提到RewriteBase作为

RewriteBase /home/yourusername/public_html/mywebsite

将这一行添加到"重写引擎在线"旁边。