Mod_rewrite在Windows和Ubuntu上有不同的结果

Mod_rewrite在Windows和Ubuntu上有不同的结果,windows,linux,.htaccess,mod-rewrite,ubuntu,Windows,Linux,.htaccess,Mod Rewrite,Ubuntu,我设置了以下重写规则 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ core/index.php [L] 并且站点架构是 newsite ﹂ .htaccess ﹂ core ﹂ index.php 如果我在Windows上使用url:http://localhost/web/newsite/test 它将重定向到/web/newsite/co

我设置了以下重写规则

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ core/index.php [L]
并且站点架构是

newsite
 ﹂ .htaccess
 ﹂ core
     ﹂ index.php
如果我在Windows上使用url:http://localhost/web/newsite/test
它将重定向到/web/newsite/core/index.php
它真的起作用了

但是如果在Ubuntu上使用urlhttp://localhost/~user1/web/newsite/test
它将重定向到/home/user1/public\u html/web/newsite/core/index.php
不是/~user1/web/newsite/core/index.php

那么,我如何解决这个问题呢?

谢谢

在规则上方添加一个
RewriteBase

RewriteBase /~user1/web/newsite/

ubuntu上的Apache试图猜测重写规则的目标是URI路径还是文件路径,但猜测不正确,因此您必须告诉它真正的相对URI基是什么。

谢谢您的回答,但是如果我使用RewriteBase,我必须在每台服务器上设置不同的RewriteBase。那么,有什么方法可以解决任何地方的问题吗?@AzureChen它根本不应该重定向,它应该只是为您提供内容。