Home>

I want to redirect all files under a specific directory to another page using SimplePress 301 Redirects. (Please let me know if it can be executed with other plug-ins.)

As an example, I want to redirect all files under the bbbbb directory (example ccccc.pdf in this example) like example.com/aaaaa/bbbbb/ccccc.pdf to example.com/ddddd/.

I was able to redirect from a fixed page to a fixed page. Is this plug-in not applicable to PDF files?

If i can solve it by editing the .htaccess file, I would like to ask you to teach it.

  • Answer # 1

    WordPress's .htaccess is as follows.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^ index \ .php $-[L]
    RewriteCond% {REQUEST_FILENAME}! -F
    RewriteCond% {REQUEST_FILENAME}! -D
    RewriteRule. /Index.php [L]
    </IfModule>

    In this case, if a "file" or "directory" that matches the accessed URL actually exists, WordPress index.php will not be executed, so it cannot be redirected by the WordPress plug-in.


    When redirecting with .htaccess,

    before the description of WordPress relations in .htaccess
    RewriteRule ^ aaaaa/bbbbb /(.*)$/ddddd/$1 [R = 301, L]


    Or maybe?