RedirectMatch并隐藏URL

时间:2015-11-12 12:18:50

标签: php apache .htaccess mod-rewrite

假设有一个名为me.com的网页,我希望/project/index.php中的文件成为主根文件。

/project/index.php看起来像这样:

<?php
header('Location: /project/site-one.html');
exit;
?>

.htaccess看起来像这样:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RedirectMatch ^/$ /project/index.php [L]

    # more rules follow

现在,如果我访问me.com,我会me.com/project/site-one.html

我想要的是,总是有/project/site-one.html/project/index.php 只需在地址栏中将me.com显示为网址。

这怎么可能?我尝试过使用RewriteRule并只传递[L]标志,但没有什么能满足我想要的效果。

1 个答案:

答案 0 :(得分:1)

您可以在root .htaccess中使用.htaccess(高于project级别):

RewriteEngine On
RewriteRule ^/?$ /project/site-one.html [L]

您应该从header(...)

中删除index.php函数调用
相关问题