Showing posts with label .htaccess. Show all posts
Showing posts with label .htaccess. Show all posts

March 31, 2015

Force your PHP Scripts to display in source code

PHP htaccess file

Generally, PHP is a server side scripting language. You cannot see your PHP scripts in your source code as PHP out puts are parsed as HTML. But, by using .htaccess file in PHP we can modify the default behaviour of PHP and we can force the scripts to visible in source code. I personally don't recommend to do it in production environment as it creates a security issue but if you are in testing phase you can use it. Okay, enough of the talk let me show you the process.

First open the .htccess file if you don't have one create one by saving the file as .htaccess nothing will be in prefix just simple .htaccess and open the file in code editor and paste the following code.

RemoveHandler cgi-script .pl .cgi .php .py
AddType text/plain .pl .cgi .php .py


That's it now you can see your php in source code. I hope you liked the tutorial. If you have any queries comment below of you can mail me at ething4pc@gmail.com

Redirect users to customized Error pages in PHP

PHP is the most power language used to create dynamic web pages. It's a Server side scripting language. We can create very secured web sites using PHP. Anyway I am not going to discuss everything about php. In this post I am giving you how to redirect the user for your customized error documents.
There is a file named .htaccess file in php if not their you can create one. .htaccess is not an extension, it's a file name it self. There is nothing like filename,htaccess it's only .htaccess. You have to create that file and put that file in your working directory.
Now open .htaccess file in the code editor paste the following lines.

ErrorDocument 401 /error_pages/401.html
ErrorDocument 404 /error_pages/404.html
ErrorDocument 500 /error_pages/500.html


Let me explain the meaning of above lines. ErrorDocument 404 says the following link is link to the error document and redirect the user to that page when ever the error 404 occurred.
error_pages/404.html is a path to the customized 404 error file and you can give it any name you like. Again no need to remember about the different types of error pages available you can search in the internet or if you wait for a few time I will post about them in our blog.

So, this is it guys. Any queries don't hesitate to comment below or mail me at ething4pc@gmail.com