Domain migration: rocky.global → app.rocky.global
This document describes the risks of moving the main application domain from rocky.global to app.rocky.global and how to mitigate them using 301 permanent redirects.1. Risks
1.1 SEO and indexing
- Risk: Search engines have indexed rocky.global. Changing the domain without redirects causes:
- Loss of rankings and organic traffic.
- Old URLs return 404 or point to the wrong site.
- Mitigation: Redirect every URL from
rocky.global(andwww.rocky.global) to the same path onapp.rocky.globalwith HTTP 301 (Moved Permanently). Search engines transfer most of the “link equity” to the new URLs and update their index over time.
1.2 External links and bookmarks
- Risk: Third-party sites, emails, and user bookmarks point to
https://rocky.global/.... Without redirects they break. - Mitigation: Same 301 redirects:
https://rocky.global/path→https://app.rocky.global/path. Links and bookmarks keep working.
1.3 Sessions and cookies
- Risk: Cookies are often set for the current host (
rocky.global). After moving toapp.rocky.global, existing cookies may not be sent, so users can be logged out. - Mitigation:
- Set
SESSION_DOMAIN=.rocky.globalin.envso cookies are valid for bothrocky.globalandapp.rocky.globalduring and after migration (if you want shared session across subdomains). - Or accept a one-time logout: after 301, users land on
app.rocky.globaland log in again; new cookies will be forapp.rocky.global.
- Set
1.4 Emails and callbacks
- Risk: Links in emails (password reset, order confirmation, etc.) and payment/API callbacks (e.g. Redsys) may use the old domain.
- Mitigation:
- APP_URL: Set
APP_URL=https://app.rocky.globalin.envso Laravel generates all new links with the new domain. - 301 redirects: Any old link (e.g.
https://rocky.global/password/reset/...) will redirect tohttps://app.rocky.global/..., so old emails and callbacks still work. - Redsys / payment gateway: Update notification and return URLs in the gateway dashboard to
https://app.rocky.global/...when possible; redirects cover any remaining old URLs.
- APP_URL: Set
1.5 CORS and Sanctum
- Risk: If the frontend or API consumers use the domain in CORS or Sanctum’s stateful domains, the old domain may stop working.
- Mitigation:
- Set
APP_URL=https://app.rocky.global; Sanctum uses this for allowed hosts. - Keep 301 redirects so that requests to
rocky.globalare redirected toapp.rocky.globalbefore hitting the app; then CORS and Sanctum see the canonical host.
- Set
1.6 SSL/TLS
- Risk: Both
rocky.globalandapp.rocky.globalmust have valid certificates. Redirects should use HTTPS on the new domain. - Mitigation: Configure SSL for both domains (e.g. wildcard
*.rocky.globalor separate certs). The application redirects tohttps://app.rocky.global.
1.7 Hardcoded domain references
- Risk: Code or config that hardcodes
rocky.global(e.g. support email, asset URLs) can point users to the wrong place. - Mitigation: Use
config('app.url')(and thusAPP_URL) for the app’s base URL. Support email (support@rocky.global) can stay as is; it’s an email address, not the app domain. No change required unless you move support to e.g.support@app.rocky.global.
2. Redirect strategy (301)
2.1 Rules to implement
- Redirect all requests from the old host(s) to the same path (and query string) on the new host, with 301:
- Preserve path and query string (e.g.
/events/123/dashboard?tab=orders→https://app.rocky.global/events/123/dashboard?tab=orders). - Use 301 so search engines and clients treat the move as permanent and update caches/bookmarks.
2.2 Where redirects are implemented in this project
-
Laravel middleware (
App\Http\Middleware\RedirectOldDomain):
Runs on every request. If the request host is one of the configured “old” domains (e.g.rocky.global,www.rocky.global), it returns a 301 to the same path/query on the canonical URL fromconfig('app.url')(i.e.APP_URL).
This works regardless of web server (Apache, Nginx, load balancer). -
Optional: Apache
.htaccess(inpublic/.htaccess):
If the app is served by Apache and the old domain points to the same document root, you can uncomment the redirect block at the top ofpublic/.htaccess. This redirects at the web server level (before PHP) and reduces load.
The middleware still handles any request that reaches Laravel (e.g. behind Nginx or a reverse proxy), so redirects work even if you do not use the.htaccessrules.
2.3 Configuration
-
.envAPP_URL=https://app.rocky.global
This is the canonical application URL; all new links and the redirect target use it.- Optional:
REDIRECT_OLD_DOMAINS=rocky.global,www.rocky.global
If not set, the middleware uses the default list inconfig/domain.php(see below).
-
config/domain.php(optional)redirect_old_domains: list of hosts that must be redirected toAPP_URLwith 301.
3. Checklist before and after cutover
Before:- DNS:
app.rocky.globalpoints to the same application server (or load balancer). - SSL certificate valid for
app.rocky.global(and ideally forrocky.globalandwww.rocky.globalfor redirects). -
.env:APP_URL=https://app.rocky.global. -
.env: OptionalREDIRECT_OLD_DOMAINS=rocky.global,www.rocky.globalif you use custom list. - Payment gateway / Redsys: Update notification and return URLs to
https://app.rocky.global/...where possible (redirects still cover old URLs). - Deploy middleware and (if used)
.htaccesschanges so 301s are active as soon as both domains hit the app.
- Test:
https://rocky.globalandhttps://rocky.global/any/pathreturn 301 andLocation: https://app.rocky.global/.... - Test: Login, password reset, and payment return URLs work via
app.rocky.globaland via old links (through redirect). - Google Search Console: Add
https://app.rocky.globalas a property and, if needed, submit a change of address or sitemap for the new domain. - Monitor logs and errors for broken links or callbacks still using the old domain; 301s should handle them transparently.
4. Summary
- Risks: SEO, broken links, sessions/cookies, emails/callbacks, CORS/Sanctum, SSL, hardcoded URLs.
- Mitigation: Use 301 redirects from
rocky.globalandwww.rocky.globaltoapp.rocky.global(same path and query), setAPP_URL=https://app.rocky.global, and optionallySESSION_DOMAIN=.rocky.globalif you want shared cookies. Redirects are implemented in Laravel middleware (and optionally in Apache.htaccess).
