I want to redirect all pages from the .com/blog
directory to the .com/error
directory.
我想将.com / blog目录中的所有页面重定向到.com / error目录。
I have searched the web, and found loads of different ways of doing it, but I want it to redirect to a single page.
我搜索过网络,发现了大量不同的方法,但我希望它能重定向到一个页面。
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 / blog / index.nonexisting重定向到.com / error / index.nonexisting。
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
.
我希望第一个目录中的所有文件都重定向到某个文件,所以如果你去.com / blog / whatever.php它会转到.com / error / index.php,如果你去.com / blog / random.xml您将被重定向到.com / error / index.php。
Is there any way to do this?
有没有办法做到这一点?
1 个解决方案
#1
7
Try putting this in your .htaccess:
试着把它放在你的.htaccess中:
RewriteEngine on
RewriteRule ^blog/(.+) error/index.php [L,R]
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.
如果你想要301重定向,用R = 301替换R,如果你不想要外部重定向,则完全去除R.
#1
7
Try putting this in your .htaccess:
试着把它放在你的.htaccess中:
RewriteEngine on
RewriteRule ^blog/(.+) error/index.php [L,R]
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.
如果你想要301重定向,用R = 301替换R,如果你不想要外部重定向,则完全去除R.