Get a Pentest and security assessment of your IT network.

Cyber Security

Fix Back-end URL Redirects

TL;DR

Your website’s URLs are changing unexpectedly because of something happening on your server (the ‘back-end’). This guide shows you how to find the cause and fix it, covering common issues like redirects, rewrites, and database problems.

1. Understand What’s Happening

Before fixing anything, figure out *when* the URLs started changing. Did it happen after a website update? A server change? Knowing this helps narrow down the problem.

2. Check Your .htaccess File (Apache) or Web Server Configuration (Nginx/IIS)

These files control how your web server handles requests and can cause redirects or rewrites. They’re often the culprit.

  • Apache (.htaccess): Look for lines starting with Redirect, RewriteRule, or RewriteCond.
  • Nginx: Check your server block configuration file (usually in /etc/nginx/sites-available/). Look for rewrite directives.
  • IIS: Use the IIS Manager to check URL Rewrite rules under your website’s settings.

Example .htaccess redirect:

Redirect 301 /old-page.html /new-page.html

If you find unwanted redirects, comment them out (add a ‘#’ at the beginning of the line) or remove them.

3. Examine Your Application Code

Your website’s code (PHP, Python, Node.js, etc.) might be generating the URLs. Look for functions that handle redirects or URL creation.

  • PHP: Search your codebase for header('Location: ...'). This is a common way to perform redirects in PHP.
  • Python (Flask/Django): Look for functions like redirect().
  • Node.js (Express): Check for res.redirect(...).

Example PHP redirect:

header('Location: /new-page.html'); exit;

4. Investigate Database Changes

If your website uses a database (MySQL, PostgreSQL, etc.), the URLs might be stored there. Changes to these records could cause unexpected redirects.

  • Check relevant tables: Look for tables containing URL slugs or redirect information.
  • Review recent updates: See if any data was recently modified in those tables.

Example SQL query to find redirects (assuming a table named ‘redirects’):

SELECT * FROM redirects WHERE old_url LIKE '%old-page%';

5. Clear Caches

Caching can sometimes store outdated redirect information. Clear all caches:

  • Browser cache: Clear your browser’s cache and cookies.
  • Server-side cache: If you use a caching plugin or system (e.g., Varnish, Redis), clear its cache.
  • CDN cache: If you use a CDN (e.g., Cloudflare), purge its cache.

6. Check for Plugins/Extensions

If you’re using a CMS like WordPress, Joomla, or Drupal, a plugin or extension might be causing the redirects.

  • Deactivate plugins one by one: Temporarily deactivate each plugin to see if it resolves the issue.
  • Check plugin settings: Review the settings of any redirect-related plugins.

7. Server Logs

Your server logs can provide valuable clues about what’s happening.

  • Access logs: Show all requests made to your server, including redirects.
  • Error logs: May contain information about errors related to URL handling.

8. Security Considerations

Unexpected redirects can be a sign of cyber security compromise. If you suspect malicious activity:

  • Scan your server for malware.
  • Review user accounts and permissions.
  • Update all software to the latest versions.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation