.htaccess文件夹的URL重写

.htaccess文件夹的URL重写,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我在example.com/app上有一个应用程序,文件夹中有signin.php、signup.php、index.php等 现在,客户端希望在example.com/signin.php等网站上访问应用程序,但我希望将应用程序文件保存在应用程序文件夹中,以便更好地管理 我试着使用它,但我无法访问根目录中已有的文件: RewriteCond %{HTTP_HOST} ^example\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$

我在example.com/app上有一个应用程序,文件夹中有signin.php、signup.php、index.php等

现在,客户端希望在example.com/signin.php等网站上访问应用程序,但我希望将应用程序文件保存在应用程序文件夹中,以便更好地管理

我试着使用它,但我无法访问根目录中已有的文件:

RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{REQUEST_URI} !^/app/
RewriteRule (.*) /app/$1

有没有办法排除根目录中的页面受到影响?或者有更好的方法吗?

你不能让http服务器指向应用程序文件夹作为基础吗?

查阅apaches mod_rewrite的文档,查看RewriteMap指令。使用该选项,您可以轻松命名所有想要或不想要重写的名称

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/app/
RewriteRule (.*) /app/$1
使用-f和-d可以确保它不会弄乱任何现有的文件或目录