Erick Rodriguez
Erick Rodriguez

Reputation: 1

Rewriting from a SEO friendly URL to another SEO friendly URL on the same site

For our SEO needs in my company, we need to change some SEO URLs to another ones through 301.

Example:

/seo/keywords-1-2-3/ to /seo/mynew301page-1-2-3/

Is there some Apache rewrite rule that I can specify that certain URLs should be redirected to the new one?

Upvotes: -1

Views: 211

Answers (2)

Janvi Arora
Janvi Arora

Reputation: 1

You can do it n two ways:

  1. .htaccess
  2. httpd.conf

Mostly the .htaccess configuration method is used.

So you can use this code in your .htaccess file:

RewriteEngine On
RewriteRule ^/seo/keywords-1-2-3/ /seo/mynew301page-1-2-3/ [R=301,L]

Upvotes: 0

LazyOne
LazyOne

Reputation: 165088

As simple as this:

Redirect 301 /seo/keywords-1-2-3/ /seo/mynew301page-1-2-3/

The above will redirect ALL requests for URLs that start with /seo/keywords-1-2-3/ to /seo/mynew301page-1-2-3/. For example: /seo/keywords-1-2-3/something?say=hello ==> /seo/mynew301page-1-2-3/something?say=hello

If it has to be precise match (only /seo/keywords-1-2-3/ and not /seo/keywords-1-2-3/something, then use this one:

RedirectMatch 301 ^/seo/keywords-1-2-3/$ /seo/mynew301page-1-2-3/

The same, but using mod_rewrite:

RewriteEngine On

# broad (base) match
RewriteRule ^/seo/keywords-1-2-3/(.*)$ /seo/mynew301page-1-2-3/$1 [R=301,L]

# exact match
RewriteRule ^/seo/keywords-1-2-3/$ /seo/mynew301page-1-2-3/ [R=301,L]

Upvotes: 0

Related Questions