简体   繁体   English

使用.htaccess重定向子页面的流量

[英]Using .htaccess to redirect traffic from subpages

Im having a hard time trying to find a solution that works for my situation. 我很难找到适合我情况的解决方案。

I want to redirect any visitors to my website to / using htaccess. 我想将任何访问者重定向到我的网站/使用htaccess。

For example, if someone goes to www.example.com/thisisapage then it will redirect them back to / 例如,如果有人访问www.example.com/thisisapage,那么它会将它们重定向回/

But i need it for every page on my site automatically. 但我需要自动为我网站上的每个页面。

I have tried the following 我尝试了以下内容

RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteRule $ / [R=302,L]

Any help would be greatly appreciated. 任何帮助将不胜感激。

Cheers, 干杯,

You can use the following : 您可以使用以下内容:

RewriteEngine on


RewriteCond %{REQUEST_URI} !^/index
RewriteRule ^.+$ / [L,R]

This will redirect 这将重定向

  • /foobar (excluding the dir index page) / foobar(不包括目录索引页面)

to

  • / /

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

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