.htacess重定向目录单页 [英] .htacess redirect directory to a single page
问题描述
我要重定向的的 .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.
所有的我都试过的事情重定向到文件名相同,但在不同的目录中。例如,的.com /博客/ index.nonexisting
重定向到 .COM /故障/ index.nonexisting
。
All the things I have tried redirect to the same file name, but in different directory. For example, .com/blog/index.nonexisting
redirects to .com/error/index.nonexisting
.
我想在第一个目录中的所有文件重定向到某个文件,所以如果你去的.com /博客/ whatever.php
那就去< $ C C> .COM /故障/ index.php文件 $,如果你去的.com /博客/ 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 .com/blog/whatever.php
it would go to .com/error/index.php
, and if you go to .com/blog/random.xml
you would be redirected to .com/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重定向,并且摆脱<$ C $的ç>研究全部,如果你不希望外部的重定向。
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重定向目录单页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!