Sean H
Sean H

Reputation: 1066

Canonical redirect change between app versions

I have an iOS app which connects to an API running on a website.

For SEO purposes I want to add a canonical redirect on the website from www.mysite.org to just mysite.org.

The current version of the app connects to www.mysite.org/api. In the new version of the app I will change this path to the new canonical URL of mysite.com.

But that would affect users of the current version of the app.

Is there a way to do this that doesn't affect any users adversely?

Thanks Sean

Upvotes: 0

Views: 26

Answers (1)

Mark Walker
Mark Walker

Reputation: 1279

Not tested the code but something along these lines should work. Concept is to only force a redirect to root domain if the request doesnt start with api.

So normal pages are redirected and api works on both www and without.

RewriteCond %{HTTP_HOST} ^example.org [NC]
RewriteCond %{REQUEST_URI} !^/api$ [NC] 
RewriteRule ^(.*)$ http://www.example.org/$1 [L,R=301,NC]

Upvotes: 1

Related Questions