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
https://forums.phpfreaks.com/topic/110319-phpini-or-htaccess/
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
https://forums.phpfreaks.com/topic/110319-phpini-or-htaccess/#findComment-566028
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
https://forums.phpfreaks.com/topic/110319-phpini-or-htaccess/#findComment-566033
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.