Mobile app version of vmapp.org
Login or Join
Steve110

: How to bulk redirect URLs and replace one path segment? I have several URLs in a WordPress website I would like to rewrite and then make a 301 redirect. URLs are of the form www.example.com/prodotto/something-after

@Steve110

Posted in: #301Redirect #Htaccess #UrlRewriting

I have several URLs in a WordPress website I would like to rewrite and then make a 301 redirect.

URLs are of the form
example.com/prodotto/something-after

These URLs should be changed to
example.com/shop/something-after

Should I use URL rewrite rules in .htaccess? I have used this rule, but it doesn't work:

# 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 ^/?prodotto/(.*)$ www.example.com/shop/ [R=301,L]
</IfModule>
# END WordPress'

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Steve110

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cooney921

You can use Apache Module mod_rewrite:

RewriteEngine ON
RewriteRule ^/?stringtochange/(.*)$ www.domainname.com/newstring/ [R=301,L]


The string after stringtochange is passed to the other url containing newstring in the variable.

So for example, if you access example.com/stringtochange/cool-page.html it will get redirected to example.com/newstring/cool-page.html.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme