Knowledgebase

URL Rewriting and Pretty URLs Print

  • developersgitdeployment, developers, migration, htaccess, permalinks, troubleshooting, wordpress, php, errors, redirects
  • 0

Making URLs readable and stable.

WHY IT MATTERS

Readable URLs are easier to share, better for search, and do not expose your application's internal structure.

HOW IT WORKS

The web server rewrites an incoming request internally to a different path, invisibly to the visitor. A request for /products/blue-shirt is handled by index.php with parameters.

IN WORDPRESS

Settings > Permalinks. Choosing a structure writes the necessary rules to .htaccess.

Re-saving permalinks regenerates them, which fixes 404s on every page but the homepage after a migration.

IN FRAMEWORKS

Most ship with an .htaccess routing all requests to a front controller. Ensure it transferred during deployment; its absence is a common post-migration fault.

COMMON PROBLEMS

404 on every page but the homepage: rewrite rules missing or mod_rewrite not active

Rules working locally and not on the server: different server configuration

Rules overwritten by the application, when placed inside its managed block

CHANGING URL STRUCTURE ON A LIVE SITE

Redirect the old URLs to the new ones. Otherwise every link and search result pointing at the old structure breaks.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot