cooldude832 Posted June 15, 2008 Share Posted June 15, 2008 I want my site to revert to a single page example mysite.com/articles/15.php runs the script mysite.com/index.php?page=articles/15.php second example mysite.com/fishing.php goes to mysite.com/index.php?page=fishing.php then index.php gathers content out of a database How can I do it? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted June 15, 2008 Share Posted June 15, 2008 .htaccess file (goes in the document root of your website): RewriteEngine on RewriteRule ^fishing\.php$ index.php?page=fishing.php Also consider this example: RewriteEngine on RewriteRule ^(.*?)/$ index.php?page=$1.php The above will redirect "mysite.com/any_name/" to "mysite.com/index.php?page=any_name.php". Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 15, 2008 Author Share Posted June 15, 2008 RewriteEngine on RewriteRule ^(.*?)/$ index.php?page=$1.php where is $1 defined? Also will it work on mysite.com/articles/september/01.php Quote Link to comment Share on other sites More sharing options...
thebadbad Posted June 15, 2008 Share Posted June 15, 2008 $1 is the matched input from inside the first set of parentheses. Just try if it works (access it with mysite.com/articles/september/01/ - not with the .php extension). If it doesn't, try with this instead: RewriteEngine on RewriteRule ^(.+)/$ index.php?page=$1.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.