I have developed an website, and I was using just HTML, JS and CSS codes.
The pages are created like www.example.com/Home, it means no format...
My website was running well before i put this single line php code in it:
<?php include 'PageLoader_ST.php' ?>
Here is the code in screenshoot:
And here is the code read by Browser:
I am a little confused on how can i make it work? I don't wan't to use this format Home.php, is it possible anyway?
A file that should be parsed as php code, must have the file extension .php. There is no way around this.
The url and the real file name on disk must not be the same. Very often (and when you use a framework, almost always) they do not correspond. This is achieved through url rewriting. With an Apache server this is done with a .htaccess file.
You could use it to remove the .php extension.
In order to use PHP two things must happen.
1.) PHP must be installed on your server (I'm assuming apache), you can do this by either installing a windows lamp package (like xampp or wamp. installing standalone on a windows server is kinda tricky) Or if you're using a linux environment you can install PHP along with apache by installing the relevant packages.
2.) Your files must have a .php extension in order to tell the php engine that the file contains php script and it must be run through the engine to parse the scripting.
This is a design element in PHP and it is intentional.
EDIT: after reading your question again it looks like you're trying to have your homepage be mydomain.com/Home instead of mydomain.com/home.php.
Having a file that doesn't have an extension is not how you do that. Your file needs .php, and when you want to display the home page you need to use Apache rewrite rules in order for you to have the "pretty urls" affect for SEO and readability.
You can get around the .php from being visible if you use a folder structure along with 'index.php' files. Apache will look for a default file called index in each directory and use that before any others. For example if folder Home contains a file called index.php, you can still use the URL www.example.com/home/ and your site will still work.
This method will also work with a file named index.html or others.
NOTE: The Home directory can still contain other files that can be linked to but they must be linked to using the URL www.example.com/home/filename.extension
Related
I am working on a college assignment which requires me to stick with perl and cgi.pm to render webpages.
With my current implementation I have included a javascript cdn for a javascript library (p5js) and another script tag that points to a js file present in the cgi-bin folder.
All the html content seems to be working fine, but I keep getting a 404 error saying that the files can't be found, despite it being there
The webpage works fine when executed as a regular html page.
If the cgi-bin directory is not the expected location, please let me know where to place the js files as well as how to point to them using a the script tag
From the browser view the js files are static content so apache try to get it from the DocumentRoot. Put it there or better make a directory DocumentRoot/js an locate all js files there. The path part of the URL looks then like /js/p5.js
I want to read Web.Config settings through javascript file. I have below reference link which suggest the same but works ONLY when we add the code in .aspx file and not when put into .JS file.
http://www.codeproject.com/Tips/77917/Read-Configuration-Settings-of-Web-config-using-Ja
Is it possible to do that with code in .js file?
No, and you shouldn't want to (you can by changing the IIS ISAPI file handler, but NO!). The web.config file is a file that needs to be secured heavily, since it can contain usernames and passwords to databases and other resources. The web.config should not be exposed to the outside world!
That said, you might opt to create an ashx or aspx that reads a specific part of the web.config and exposes that to the page, but that is as far as I would go.
IIS will never allow the browser to directly request the web.config file... so the simple answer is "No, you can't do that with javascript".
Your only option is to stream the file via an .aspx page (or similar), but I wouldn't recommend it as it could potentially (almost certainly) be a security issue.
Edit: As Patrick says in his answer above, if you need to expose specific parts, then that would be better - but don't expose the entire file.
I am working with a simple HTML test page. I am opening it with Chrome version 40.0.2214.115. In order to test the code, I am loading a js file from my workplace.
However, the file which I loaded tries to load other js files through script tags, but does not specify http:// . This causes an error in the console, as it defaults to the file:/// protocol and is unable to load file://the/restof/theurl.js
I downloaded the file locally, and loaded it from there, adding http:// to all url's, so it would ACTUALLY use the HTTP protocol.
This worked fine. However, those links load OTHER files that also do not specify http://
Is there any way I can have the browser imply http:// to unspecified script tags, and avoid downloading and editing EVERY file just to test a small HTML page?
I think the easiest way to prevent problems like this is to actually use a very small server (like something provided by node.js or the like or lighttpd).
Obviously your files are not supposed to be delivered via the plain file protocol, so you should just use a http server. That way you can be sure they work as intended and you don't have to fiddle around with your browser on a deeper level.
If you launch chrome with the below flags this should work. Obviously not possible for production environments, but for testing it should be okay.
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
Consider using a simple local file server. If you are unsure how to, since you are developing in JavaScript, you can easily create a simple file server using Node.js which written in JS using simple middleware like node-static.
When I use Google Chrome's "Save as.." the cgi page is being downloaded as one single html and another folder with all required stuff in order to display it correctly offline. I tried many parameter but nothing worked properly as I expected. Also -p doesn't work.
GNU Wget 1.14 built on linux-gnu.
When I use -p option, get robots.txt and the .cgi file itself.
Can it be like this because of the cookies? Is there option that may fix this problem?
Is there another way? I mean for example if I put some parameters to chromium in the terminal.
Quoting from the man page:
‘-p’ ‘--page-requisites’
This option causes Wget to download all the files that are necessary
to properly display a given HTML page. This includes such things as
inlined images, sounds, and referenced stylesheets.
Problem was that I needed to use cookies to pass the log in session. So --load-cookies seems to solve my problem.
I want to upload a bunch of image files to a directory that I've set up on my ISP's free hosting service. It's something like http://home.ISPname.net/~username/subdir.
I want my Javascript code to be able to get a directory listing and then preload whatever it finds.
But getting such a thing even possible? My impression is not.
I suspect I will have to instead rename my files to 00000.jpg and upward, and attempt to detect what files are there using try.
FYI, I know that my ISP does not support using FTP protocol to get a directory listing.
Thanks for any help.
Under the assumption that your JavaScript code is code on your pages and not code on your server, then no, there's no API provided for JavaScript in a web browser other than a server-side API accessible via HTTP that you would create yourself. If the directory full of files is on the server, then it's going to have to be some server-side code that delivers the directory listing anyway. You could write such code in the server-side programming environment of your choice (including a server-side JavaScript solution, if that's what you want and if such a thing is possible at your ISP). As Pekka notes, it may be possible to simply enable directory browsing in your server, though that's generally a fairly low-level service that will deliver some sort of HTML page to you, and parsing through that might be somewhat painful (compared to what you could get from a tailor-made service).
Another, simpler thing you could do would be to upload a manifest file along with the other image files. In other words, create the directory listing in some easy-to-digest form, and maintain it separately as a simple file to be fetched.
javascript not suport directory listing in a direct way. but you can create a directory dumper php file, and send via AJAX.