.htacess重定向目录单页

编程入门 行业动态 更新时间:2024-10-10 04:24:54
本文介绍了.htacess重定向目录单页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要重定向的的 .COM /博客所有页目录到 .COM /错误目录。

我在网上搜索,发现了做不同的方式加载,但我希望它重定向到一个单页。

I have searched the web, and found loads of different ways of doing it, but I want it to redirect to a single page.

所有的我都试过的事情重定向到文件名相同,但在不同的目录中。例如,的 /博客/ index.nonexisting 重定向到 .COM /故障/ index.nonexisting 。

All the things I have tried redirect to the same file name, but in different directory. For example, /blog/index.nonexisting redirects to /error/index.nonexisting.

我想在第一个目录中的所有文件重定向到某个文件,所以如果你去的 /博客/ whatever.php 那就去 .COM /故障/ index.php文件 $,如果你去的 /博客/ random.xml 你会重定向到 .COM /故障/ index.php文件。

I would like all files in the first directory to redirect to a certain file, so if you go to /blog/whatever.php it would go to /error/index.php, and if you go to /blog/random.xml you would be redirected to /error/index.php.

有没有办法做到这一点?

Is there any way to do this?

推荐答案

尝试把这个在你的.htaccess:

Try putting this in your .htaccess:

RewriteEngine on RewriteRule ^blog/(.+) error/index.php [L,R]

替换研究与 R = 301 如果你想有一个301重定向,并且摆脱研究全部,如果你不希望外部的重定向。

Replace R with R=301 if you want a 301 redirect, and get rid of R entirely if you don't want an external redirect.

更多推荐

.htacess重定向目录单页

本文发布于:2023-11-02 07:15:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   目录   htacess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!