0

With many web sites, if you use as the URL, for example, www.example.com/pages/main/index.php, you are accessing the file 'index.php' in the folder 'main' in the folder 'pages.' How would you instead program the web site so that when the URL www.example.com/pages/main/index.php is entered, the primary web application (stored directly in the site root directory) knows that this URL was entered and can serve the proper web page? This is a somewwhat general question, but it should have specific code answers and can certainly be answered, and as such was asked. The web application would be written in PHP.

TheEnvironmentalist
  • 2,694
  • 2
  • 19
  • 46

1 Answers1

1

This can be solved with .htaccess and rewrite rules.

See .htaccess rewrite to redirect root URL to subdirectory or http://coding.smashingmagazine.com/2011/11/02/introduction-to-url-rewriting/

Note that mod_rewrite should be enabled in apache settings

Community
  • 1
  • 1
silkfire
  • 24,585
  • 15
  • 82
  • 105