我要重定向的的 .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重定向目录单页
发布评论