B4J Code Snippet Really Neat! PHP redirect to port.

I have re-uploaded the ABMaterial demo to my site and have redirected a folder to the demo page.

So, how do you redirect to a port? Using my demo of ABMaterial (1.03) as an example:

Origin URL: http://coldbluelava.com/abmaterial
Destination URL: http://coldbluelava.com:13131/demo/


Well, just use this PHP code snippet:

With Dir:
PHP:
<?php header('Location: http://mysite.com:port/dir'); ?>
Without Dir:
PHP:
<?php header('Location: http://mysite.com:51042/'); ?>

If you have Ubuntu, then allow traffic to the port with this command:
B4X:
sudo ufw allow <PORT>/tcp


(With this discovery that PHP can redirect to a port, I've given myself the green light to rewrite my site.)
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
@alwaysbusy - Correct me if I'm wrong, but the AddFilter function only works from within the app itself. The PHP code is able to redirect from a non-port location.
 

Harris

Expert
Licensed User
Longtime User
I had an issue with this.
I currently use:

B4X:
<?php
     header("Location: http://xyz.com:51040/tripinspect/index.html"); 'not real of course..
?>

This works...
Any other script i got 503 "Forbidden..." (with the port example you stated...)

Not sure I understand the context of what you did...
 

aaronk

Well-Known Member
Licensed User
Longtime User
Good stuff guys! I'm just wondering, does this also mask your 'real' URL in the users browser?
No. It will just redirect the site to a new website location.

Try this:
Copy the code below into Notepad++ (or any text editor) and name it index.html
HTML:
<html>
    <frameset rows="100%" cols="*" border="0" framespacing="0" frameborder=no>
        <frame src="http://b4x.com/" SCROLLING="yes">
    </frameset>
</html>

Name the above page as index.html and upload it to your web hosting. (remember to keep a backup of your old index.html page in case you want to go back to the old index page)

When running the above code it will load the b4x.com website and when you click on links on the page the URL in the browser will remain the same.

You can also test this by running this html page in your web browser without uploading it to your hosting.
 

alwaysbusy

Expert
Licensed User
Longtime User
@aaronk Works of course not in all situations with frames. e.g. when you try to go this forum through your html, you get:

This content can’t be shown in a frame

There is supposed to be some content here, but the publisher doesn’t allow it to be displayed in a frame. This is to help protect the security of any information you might enter into this site.

Try this
•Open this in a new window
 

aaronk

Well-Known Member
Licensed User
Longtime User
Works of course not in all situations with frames. e.g. when you try to go this forum through your html, you get:

This content can’t be shown in a frame
Yeah, I know about that. Some things don't work in frames. However, there is a work around to make it work but some code needs to be added to the page you want to display in the frame.
 
Top