如何将index.php重定向到子文件夹';s文件w/wo是否使用.htaccess?
我的目录看起来像:如何将index.php重定向到子文件夹';s文件w/wo是否使用.htaccess?,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我的目录看起来像: app |---- index.php | |---- Views |---- home.php |---- include.php 我希望用户无论何时来到app目录,都能被重定向到home.php,并且仍然希望将url显示为www.example.com/app。 此外,仅使用php而不必触摸.htaccess文件是否可以实现这一点。我想在不同的服务器上分发应用程序。.htaccess是否可以位于app目录中?使用hta
app
|---- index.php
|
|---- Views
|---- home.php
|---- include.php
我希望用户无论何时来到app
目录,都能被重定向到home.php
,并且仍然希望将url显示为www.example.com/app
。
此外,仅使用php而不必触摸.htaccess
文件是否可以实现这一点。我想在不同的服务器上分发应用程序。.htaccess
是否可以位于app
目录中?使用htaccess:
RewriteEngine On
RewriteRule ^app/?$ /app/Views/home.php [L]
使用PHP: 将以下内容作为
app/index.php
:
<?php
include( "Views/home.php" );
?>
我最后用了这个:
RewriteEngine On
RewriteRule ^([a-z]+.php)$ Views/$1
这实际上将把
/whater.php
发送到/Views/whater.php
。希望这对其他人有所帮助。您可以让app/index.php检查请求,然后在那里包含相应的页面。在index.php中使用
htaccess文件是否可以位于app目录中?@PrashantGhimire Yes。但是服务器应该在子目录中处理htaccess。谢谢兄弟。让我试试