1

I want to mass redirect subdirectories/subpages/pages to a single page.

from

example.com/definicje 
example.com/definicje/521/ 
example.com/definicje/592/a.html 
etc.

to a single page

example.com/single-page/

My rewrite rule actually doesn't redirect anything:

# 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]
RewriteRule ^definicje(.*)$ http://example.com/single-page/ [R=301,L]
</IfModule>
3
  • firstly don't edit the file .htaccess or the modification will be lost on next rewrite flushing. use add_rewrite_rule instead (codex.wordpress.org/Rewrite_API/add_rewrite_rule)
    – mmm
    Oct 29 '16 at 20:11
  • Thanks for the remark but I still have no idea how to write my rewriterule correctly. Help please.
    – user105919
    Oct 29 '16 at 20:20
  • have you flush the rewrite rules as written in this page ?
    – mmm
    Oct 29 '16 at 21:23
2

The solution is to put the rewriterule just after RewriteEngine On.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^definicje(.*)$ http://example.com/single-page/ [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
2
1

There's a plugin to do redirection for all theses kinds of cases. It's simply called redirection. Search the plugin directory. I use it to redirect directories or certain pages. https://wordpress.org/plugins/redirection/

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.