繁体   English   中英

RedirectMatch和隐藏URL

[英]RedirectMatch and hide URL

假设有一个名为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即可在adressbar中将me.com显示为URL。

这怎么可能? 我已经尝试过RewriteRule并仅传递[L]标志,但是我没有想要的东西。

您可以在根.htaccess(高于project的级别)中像这样使用.htaccess:

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

您应该从index.php删除header(...)函数调用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM