MyBB Community Forums
[How To?] How can I redirect a php file to a misc.php page? - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: [How To?] How can I redirect a php file to a misc.php page? (/thread-192504.html)



How can I redirect a php file to a misc.php page? - MI-6 - 05-02-2016

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?


RE: How can I redirect a php file to a misc.php page? - .m. - 05-02-2016

check if this helps => new page using misc.php


RE: How can I redirect a php file to a misc.php page? - MI-6 - 05-02-2016

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


RE: How can I redirect a php file to a misc.php page? - Dark-Power-Invader - 05-02-2016

maybe its what you are looking for
<?php
header ('Location: /misc.php?action=example');
?>



RE: How can I redirect a php file to a misc.php page? - MI-6 - 05-02-2016

(05-02-2016, 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.


RE: How can I redirect a php file to a misc.php page? - Dark-Power-Invader - 05-02-2016

then use http;//yourdomain/misc.php instead of /misc


RE: How can I redirect a php file to a misc.php page? - MI-6 - 05-02-2016

Still got a 404 page.


RE: How can I redirect a php file to a misc.php page? - laie_techie - 05-02-2016

I would probably do a rewrite rule in your .htaccess file, so that example.php doesn't exist as a physical file.


RE: How can I redirect a php file to a misc.php page? - MI-6 - 05-02-2016

(05-02-2016, 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)


RE: How can I redirect a php file to a misc.php page? - laie_techie - 05-02-2016

(05-02-2016, 07:45 PM)MI-6 Wrote:
(05-02-2016, 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.