Jump to content

PHP.ini or .htaccess


cooldude832

Recommended Posts

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?

Link to comment
Share on other sites

.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".

Link to comment
Share on other sites

$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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.