4

すべてのページを.com/blogディレクトリからディレクトリにリダイレクトしたい.com/error

Web を検索したところ、さまざまな方法が見つかりましたが、 1 つのページにリダイレクトしたいと考えています。

私が試したすべてのことは、同じファイル名にリダイレクトしますが、別のディレクトリにあります。たとえば、 に.com/blog/index.nonexistingリダイレクトし.com/error/index.nonexistingます。

最初のディレクトリ内のすべてのファイルを特定のファイルにリダイレクトし.com/blog/whatever.phpたいので、そのファイルに移動すると に移動し.com/error/index.php、移動する.com/blog/random.xmlと にリダイレクトされ.com/error/index.phpます。

これを行う方法はありますか?

4

2 に答える 2

11

Try putting this in your .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.

于 2012-05-17T20:13:54.790 に答える