PHP Security Tips : Hiding php In URL (In Hindi)

Blogs ❯❯ PHP

Image could not load

Image By pixabay

core PHP में बनाये गए applications में developers के लिए यह important हो जाता है कि सभी security rules follow किये जाए ताकि application secure रहें।

security के मामले में काई ऐसी simple techniques हैं जिन्हे follow करके हम app को secure कर सकते हैं , इन्ही में से एक है URL से .php को remove करना।

Why hiding php is so important ?

Normally , core PHP में जब हम app बनाते हैं तो उसका URL file name पर depend होता है आग हम कोई routing package use नहीं कर रहे हैं।

For example , आपकी website का नाम test.com है , तो बाकी के लिए URLs कुछ इस तरह से होंगे -

  • test.com/aboutus.php

  • test.com/contactus.php

  • test.com/terms-and-conditions.php

अब अगर आप थोड़ा ध्यान देंगे तो हर URL के बाद में .php आ रहा है , जो न तो SEO के हिसाब से सही है और security के हिसाब से तो बिलकुल भी नहीं।

इस .php extension से किसी भी normal hacker / human को पता चल जायगा कि आपकी website PHP में बनाई गयी है , जिससे उसे hack करने के लिए एक रास्ता मिल जायगा।

Hiding PHP

तो इस blog में हम यही सीखेंगे कि URL में आ रहे .phpको कैसे remove करें। नीचे कुछ अलग अलग examples दिए गए हैं , URL में दुसरे extension को show करने या remove करने के लिए।

इन सभी configurations को .htaccess file में किया जाता है जो आपके project की root directory में होती है।

Hiding PHP as another language
AddType application/x-httpd-php .asp .py .pl
Using unknown types for PHP extensions
AddType application/x-httpd-php .bop .foo .133t
Using HTML types for PHP extensions

या इसे HTML code के रूप में hide कर सकते हैं , जिससे performance भी अच्छी होगी क्योंकि सभी HTML को PHP engine के माध्यम से parse किया जाएगा।

AddType application/x-httpd-php .htm .html
Hiding php in php.ini

हालाँकि आप php.ini और httpd.conf file में changes करके भी php extension को hide कर सकते हैं।

// File : php.ini
expose_php=Off

// File : httpd.conf
ServerSignature Off

I Hope , अब आपको समझ आ गया होगा कि कैसे URL में .php extension को hide करते हैं।

Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook