Page 1 of 1

Preview php when webserver is running

Posted: Sat Mar 28, 2020 8:52 am
by acroboy
I have read this statement: "You cannot preview pages with PHP in your browser. They can only be viewed on a webserver with PHP installed."

However I have a webserver running and can preview pages with localhost with the correct browser url.

My computer is:
running php server
localhost directory is c:\websites

Wysiwyg settings:
Page property file extension php
Preview folder http://localhost/flowers

Publish to: My Computer
URL: http://localhost/flowers
Host: C:\Websites\flowers
Folder: C:\Websites\flowers

The page used is index.php

Publishing the index.php page is done correctly to the Host directory as index.php

Preview displays url in browser -> localhost/flowers/index.html This url does not have the correct .php extension on the page.
Manually changing the extension in the browser url to .php displays the index.php page correctly.

Is it possible to have the page extension correctly displayed in the preview browser, to accurately reflect the page extension?
If the preview sent the correct page extension .php it would be solved.

Re: Preview php when webserver is running

Posted: Sat Mar 28, 2020 9:14 am
by WWBman
Using wwb preview will change index.php to index.html as you have seen.
This is because WWB Preview doesn't know about the localhost and uses a 'temp' folder.
You should preview it by using the url localhost/flowers directly from the browser (i.e. not the wwb preview option).

Re: Preview php when webserver is running

Posted: Sat Mar 28, 2020 10:14 am
by Pablo
Go to Tools -> Options -> Publish
and uncheck 'Remove PHP code during preview'.

Re: Preview php when webserver is running

Posted: Sat Mar 28, 2020 12:21 pm
by acroboy
Thanks Pablo.

Unchecked that option as you instructed.

This solves the problem, and the extension is now displayed in the browser url correctly as .php
and page now displays correctly.

Regards,
Acroboy