How to hide apache server version? - php

1] When i open any web page & view source it. We have JS & CSS. While click on that i'm able to see each JS & CSS file.
Can we manage it like while on click .js & .css file not open
2] Website hosted on linux server. Through tools hackers are able to view Apache server version. Any way to hide it?

No, JavaScript and CSS files are open to the browser, hence they are opened to the user. You can try to obfocusate them, but that will only stall a determined user.
The server version is shown when an error (404, 500) occurs, you can override that default message with your own pages using .htaccess.

CSS and JS files will be seen by anyone and everyone . They work on HTTP ;) BTW... what you want to hide is your server-side code, like asp,jsp,php. The source code of those files cannot be seen.
To your second question:
Open your .htaccess and put the following it.
ServerSignature Off
This way, for any error, it will not show what server or version you are using.
Hope it answers you :)

When an user gets programm he gets code which will be executed. On the desktop it may be binary data for example. In web development there is no binary data, browser gets code, so user does. You may only obfocusate it.

Related

Wordpress site failes to load js and css

I have this weird problem with my Wordpress Website. I worked on localhost and afterwards I tied to get my site online but i modified some configuration files and i don't know witch one is the fault. I am using XAMPP. The website right now is seems to not load js and css. Also on console log it gives 404 error for not fiinding the files it needs.
Landing page:enter image description here
Another Page:enter image description here
do you use gzip compression or such as it? if yes try to disable it, and make sure you have the right path
First, check that the file permissions are correct.
Also, if you have changed anything on your .htaccess files, overwrite them with the default ones: https://github.com/WordPress/WordPress
Also it's always a good idea to go to the permalinks page (/wp-admin/options-permalink.php) to update the links of all dependencies to the new URL.

PHP files will not stop opening locally

I am not sure what is going on here but I was working on configuring my apache server today but after a load of hassle gave up and just installed MAMP instead. Problem is that now when I open a local php file as soon as it opens another one opens until I close Firefox. When I open the file with Chrome all that is displayed is code? A page is fine until I change the extension from .html to .php
It makes no difference where the file is located (ie local host or desktop).
Has anyone else had this problem? I suspect it may be something to do with installing apache manually and then MAMP? Something must have gone wrong along the way.
Perhaps it is possible to completely uninstall apache and start again, but I have no idea how to do this!
Thank you for any help,
Margate
Doubling clicking PHP files in a File Explorer type thing or opening from the file system with the Open dialog of a browser will open them as regular HTML or Text (depending on the browser). To get them to work as PHP you have to go as if to a webpage, since PHP code is interpreted by the webserver not the browser. I.e. http://localhost/somefile.php
And make sure links to PHP pages in your site are relative links. I.e. <a href='/somefile.php'>Somefile</a> and not file system links, i.e. <a href='file:///c:\webroot\somefile.php'>Somefile</a>. PHP has to go through the server. The same goes for HTML files too. If you serve filesystem links, the links will not work for anyone else anyway.

Can we acces a file in C or D drive or any out side drive from a html/php program file in in wamp webserver(localhost server)?

I have a simple html program. It has a link, targeted to a pdf file.
Please see the program here
filename : invoice.html
My invoice
Here when I click on the link, pdf file will be open. Working well.
Then I called the same file from my localhost wamp server.
http://localhost/invoice.html.
But When I call the same program from my localhost, my link is not working!!!
Can you explain me why it is not working or how I can activate the link. Is there any option in Apache server or php settings ?
What's an "out side drive"?
I have a simple html program
HTML is not a programming language - its a data construct / declaration.
Here when I click on the link...Working well....http://localhost/invoice.html...not working
Does that mean that it works when you load the HTML file directly from your filesystem?
why it is not working or how I can activate the link
Certainly it has got nothing to do with Perl, PHP, Apache nor WAMP (the tags on your post). The problem is on your browser.
Is there any option in Apache server or php settings ?
No - because the problem is strictly client side.
I assume that the target file exists on the machine where you are running the browser.
It would have helped if you'd said which browsers you had tested this with. I would have expected it to have worked. Did you get an error message?
did you check if apache server is running on localhost? try to stop and restart the server and check if it works.
The link points to the C:\invoice.pdf on the client side. I wonder if this is what you want. It's more likely that you setup another Directory and alias in httpd.conf which points to C:\, then change the link accordingly.

php code displaying on web page instead of working behind the scene

I have an index.html in my wampserver www directory. On this html, there is a link for a user to upload file. When I hit the link, I select files to upload but instead of the uploadmanager.php which i have tested in my eclipse debugg environment to work, it displays the some part of the code on the web page without doing anything thing. This is not what I expect. Can someone please tell me what is wrong? Thank you.
sound like you are using php-short-open-tags (<? instead of <?php) without enabling this in your php.ini. change your php.ini or use the standart open-tags to solve this.
Are you sure you enabled PHP in WAMP?
Try creating a new uploadmanager.php file directly in wamp/www (or whatever subdirectory) and paste the code from your tested uploadmanager script into the new file. Then try to run it in WAMP.
I think it is a permissions problem. I copied an index.php file into a c:/wamp/www/subdirectory and it only displayed the code. Once I created a new index.php file and pasted the contents of the old file into it, it worked perfectly.
Are you posting to the uploadmanager.php page? Are you getting an error or just seeing the code? Can you post the code from the index.html page that handled the form and the part of the php code you're seeing for us to look at?
Every now and then I have Apache serving the .php as downloadable files instead processing them on the server, but only with random requests.
Some reasons, why this might happen, are
PHP misconfiguration
PHP-files in a directory without execute rights
wrong content type sent
timeout from script execution
In my situation the last bullet is the most dangerous, but luckily it seems to show up only immediately after modifying some of the .php files. I haven't tracked the problem any deeper yet, but it seems to relate some filesystem level operations (as the disk I/O is a bottleneck) and presents itself only in testing env.

Opening a local file in Eclipse from the web

Right now, when I notice a problem on a page on my PHP web site, I have to look at the URL, mentally deduce what file is responsible for displaying that page, then navigate the Eclipse PDT file tree to open that file. This is annoying and uses brain power that could have been applied to solving the issue instead.
I would like my PHP web site to display on every page a link that I could click to automatically open the correct file in Eclipse.
I can easily compute the complete absolute path for the file I need to open (for example, open C:/xampp/htdocs/controllers/Foo/Bar.php when visiting /foo/bar), and I can make sure that Eclipse is currently open with the correct project loaded, but I'm stuck on how I can have Firefox/Chrome/IE tell Eclipse to open that specific file.
Edit
I'm going along the way of a data: URI, by adding a link to my file that contains the name of the file, with an unusual MIME type.
<a href="data:link/php;base64,IkM6XHhhb[snip]GhwIgo=">
View controller
</a>
The base64-encoded content is the absolute path to the file on my computer. When I click the link, Firefox lets me bind the content type to a new application, so I chose a batch file I wrote myself:
for /f "delims=" %%i in (%1) do (
notepad.exe "%%i"
)
This works. Now, I would like the file to be opened in the already opened window of Eclipse. What do I have to replace notepad.exe with in the above batch?
[pathtoeclipse]\eclipsec.exe -name Eclipse --launcher.openFile [fullpathtoyourfilehere]
I am not sure if it works with Galileo (i am on Helios)
Further reading: https://bugs.eclipse.org/bugs/show_bug.cgi?id=4922 (it is a long, long story)
I've tried similar things in the past, but this isn't as easy as it should be. The end result was always that Firefox would need an extension to execute a local file (I never found one that would do the job), and IE won't do it at all any more (save, maybe, for some complicated proprietary VBScript/WScript).
I see two workarounds to do this:
A function that displays the file path on your page in a big fat dialog window, making it easy to copy and paste into the Windows + R "Execute" Dialog
Alternatively, registering a custom Protocol (e.g. eclipse://) in your operating system, and tying that protocol to Eclipse. This is a pretty great way actually, I haven't tried this yet but definitely will in the next project I need this. Mozillazine: Register protocol (see the .reg file example)
You get the local path with FILE.
Maybe you try something like this?
<?php
'127.0.0.1' == $_SERVER["REMOTE_ADDR"] and print __FILE__;
?>
Is integrating Eclipse with Xdebug an option? I've done this with TextMate so that generated error messages are clickable to take me to the correct line in the right file. (See this question for details).

Categories