Note that there are some explanatory texts on larger screens.

plurals
  1. POmod_rewrite for dynamically mapping SEO friendly links directly to individual files, without routing via front controller
    primarykey
    data
    text
    <p>I'm looking for an SEO friendly url rewrite rule that would work for any common PHP site that doesn't have a front controller. It would map the SEO friendly url directly to the PHP file that is found to exist on the server and convert the remaining URL branches to standard URL parameters.</p> <p>For example:</p> <p><strong><em>/folder1/folder2/folder3/page/var1/val1/var2/val2/var3/val3</em></strong></p> <p>would map to:</p> <p><strong><em>/folder1/folder2/folder3/page.php?var1=val1&amp;var2=val2&amp;var3=val3</em></strong></p> <p>Now, here's the tricky part. Since the rewrite rules need to be completely agnostic to all the names of folders, pages, and variables, it would need to base the rewrite of the URL parameters on the exact location along link where can be found a file that exists along the path. For instance, consider if the following file happened to exist (hypothetically) off the document root: <strong><em>/folder1/folder2.php</em></strong><br> In this case, the following remapping would be legitimate and acceptable:<br> <strong><em>/folder1/folder2.php?folder3=page&amp;var1=val1&amp;var2=val2&amp;var3=val3</em></strong></p> <p>This would be the ultimate rewrite rule for many traditional websites that have already been built that want their URLs and parameters to instantly become URL-friendly.</p> <p>The only examples that I have found involve mapping everything to work with a single front controller or otherwise hard-coded files in the rule that are expected to exist rather than have mod_rewrite detect their existence dynamically. They're related, but not flexible for any file that is found to exist:</p> <ul> <li><a href="http://www.sitepoint.com/forums/showthread.php?t=363420" rel="nofollow noreferrer">http://www.sitepoint.com/forums/showthread.php?t=363420</a> </li> <li><a href="https://stackoverflow.com/questions/117931/apache-modrewrite-one-rule-for-any-number-of-possibilities">apache mod_rewrite one rule for any number of possibilities</a> </li> <li><a href="https://stackoverflow.com/questions/1867373/recursive-mod-rewrite-for-search-engine-friendly-urls">Recursive mod_rewrite for search engine friendly urls</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload