Mobile app version of vmapp.org
Login or Join
Shanna517

: Redirect all pages within subdirectory to new page After redoing my webshop, I need to redirect every URL within a certain directoy to a new page. All URLs beginning ith example.com/shop/...

@Shanna517

Posted in: #Htaccess #ModRewrite #Redirects #Subdirectory #Wordpress

After redoing my webshop, I need to redirect every URL within a certain directoy to a new page.

All URLs beginning ith example.com/shop/... should be redirected to the page located at example.com/products/.

I'm using this wordpress plugin for redirections, but I don't know if it can handle it or I need to edit the htaccess file or something.

.htaccess:

# 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 ^shop/ /products/ [R=302,L]
</IfModule>

# END WordPress

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shanna517

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

That WordPress plugin should be able to handle this, but otherwise it's just a one-liner in .htaccess (which will also be more efficient):

RewriteRule ^shop/ /products/ [R=302,L]


The above directive should go after the RewriteEngine and RewriteBase directives but before any other WordPress stuff.

This redirects /shop/<anything> to /products/.

Change the 302 (temporary) redirect to 301 (permanent) when you are sure it's working OK. Temporary redirects are easier to test since they are not cached by the browser.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme