TopTomato
TopTomato

Reputation: 585

Using .htaccess how can I create a redirect based on if a string exists in the URL?

I have on my website many, many pages that contain the following string (not exact to protect privacy here) in the URL: some-media-company

for example the url would read like this: www.mywebsite.com/some-media-company/album-product-display

Because of legal issues I need to redirect all URL’s that contain the string ‘some-media-company’ to a designated landing page.

Can this be done in the .htaccess file? If so how?

fyi - i realize there are some posts here asking similar question but i was not able get a satisfactory results using any of the responses.

much thanks in advance!

Upvotes: 1

Views: 28

Answers (1)

anubhava
anubhava

Reputation: 786291

You can use this rule in your site root .htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} some-media-company [NC]
RewriteRule ^ /other-page? [L,R=301]

Upvotes: 1

Related Questions