WordPress.org

Ready to get started?Download WordPress

Ideas

.htaccess URL rewriting

  1. donottumbledry
    Member

    12345

    Call me daft here, but there has been a lot of talk about the URL rewriting that WordPress does behind the scenes for those of us that use friendly-URL's. As I understand it the rewriting is done using SQL queries and a fair old whack of PHP code to process and decipher the URL and translate it into a category or page or post or attachment etc.

    However, using rewrite rules inside a .htaccess file is a lot lot lot faster. Mostly because it's done using the Apache (or IIS for Windows servers) low-level engines rather than the higher level PHP, MySQL and ultimately WordPress applications and software. I know from experience that .htaccess rewrites are lightening fast and can handle huge amounts of conditional statements and URL options in a very short space of time, without adding any overhead to page load times or server resources.

    If WordPress were to generate a .htaccess rewrite rule set for the specified friendly-URL then there would be no need for expensive SQL queries to determine what the URL specified should relate to. The rewrites would reformat the incoming URL's into a single, predetermined order that the WordPress software does not need to do any more processing with, thus streamlining the whole process of retrieving a specified page/post/etc.

    Posted: 3 years ago #
  2. Techie
    Member

    Are you proposing to include a rewrite for every "old URL" to the "new URL" in the .htaccess? I think that would be the only way to do it without having PHP and mySQL lookups.

    I think that could be really slow for sites with thousands of posts. Are there any benchmarks for that many rewrites in an .htaccess?

    Posted: 3 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    9 Votes
  • Status

    Sorry, not right now