MyBB Community Forums

Full Version: How can I redirect a php file to a misc.php page?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So basically, what I want to do is have Example.php "redirect" to /misc.php?action=exampleaction.

And by "redirect" I mean that I want to have it so it just grabs the content of that misc.php page and serve it while still on Example.php

Is there a way to do this with MyBB?
check if this helps => new page using misc.php
No, I'm trying to make a php file in the root of the forum that will serve the content that is generated when going to /misc.php?action=example
maybe its what you are looking for
<?php
header ('Location: /misc.php?action=example');
?>
(2016-05-02, 06:16 PM)Dark-Power-Invader Wrote: [ -> ]maybe its what you are looking for
<?php
header ('Location: /misc.php?action=example');
?>

This gave me a 404 error when I went to the php file.
then use http;//yourdomain/misc.php instead of /misc
Still got a 404 page.
I would probably do a rewrite rule in your .htaccess file, so that example.php doesn't exist as a physical file.
(2016-05-02, 06:49 PM)laie_techie Wrote: [ -> ]I would probably do a rewrite rule in your .htaccess file, so that example.php doesn't exist as a physical file.

How would I do that? (I'm horrible with .htaccess files)
(2016-05-02, 07:45 PM)MI-6 Wrote: [ -> ]
(2016-05-02, 06:49 PM)laie_techie Wrote: [ -> ]I would probably do a rewrite rule in your .htaccess file, so that example.php doesn't exist as a physical file.

How would I do that? (I'm horrible with .htaccess files)

Please note that the following code is not tested, but should serve as a starting point.

RewriteEngine On
RewriteRule "^example\.php$" "misc.php?action=exampleaction" [L]
RewriteRule "^example\.php\?(.*)?$" "misc.php?action=exampleaction&$1" [L]

The first RewriteRule matches example.php, while the second one includes an optional query string.

L is a flag which says that if a request matches the RewriteRule, don't process any other RewriteRules.