简体   繁体   English

将子目录重定向到根子目录,而无需更改URL PHP

[英]Redirect subdirectory to root subdirectory without changing url PHP

https://example.com/app1

This is my subdirectory and it has one index.html file running on apache server. 这是我的子目录,它在Apache服务器上运行一个index.html文件。

I need to redirect all the requests to this directory like https://example.com/app1/* to https://example.com/app1 without changing the URL. 我需要在不更改URL的情况下将所有请求重定向到该目录,例如https://example.com/app1/*https://example.com/app1

If user access to https://example.com/app1/test it should be redirected to https://example.com/app1 but URL should remain same as https://example.com/app1/test 如果用户访问https://example.com/app1/test ,则应将其重定向到https://example.com/app1但URL应与https://example.com/app1/test保持相同

You can use this rule in your public_html/. htaccess 您可以在public_html/. htaccess使用此规则public_html/. htaccess public_html/. htaccess : public_html/. htaccess

RewriteEngine on

RewriteRule ^app1/((?!index\.html).+)$  /app1/ [NC,L]

Options +FollowSymlinks RewriteEngine on RewriteRule ^([a-zA-Z0-9_-]*)$ index.php [nc,qsa]

This one worked for me. 这个为我工作。

Thanks to all. 谢谢大家。

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

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