Interview Questions.

Top 100+ Htaccess Interview Questions And Answers


Top 100+ Htaccess Interview Questions And Answers

Question 1. What Is .Htaccess?

Answer :

.Htaccess documents are configuration files of Apache Server which offer a manner to make configuration changes on a in step with-listing foundation.

Question 2. Why Do We Use This And Where?

Answer :

Using this “.Htaccess” file, we will manage “Hypertext Preprocessor.Ini” and “httpd.Conf” record.

File Maker Interview Questions
Question three. What Can Be Done With .Htaccess File?

Answer :

Some examples of what can be accomplished with a .Htaccess record. They are all protected on this educational:

Define custom blunders pages
Banning certain IP addresses from gaining access to your website
redirecting users to other pages / web sites
password protecting directories
allowing positive PHP modules
enabling SSI (server side includes)
Question four. How To Create .Htaccess Files?

Answer :

Creating a .Htaccess report may be very clean and can be performed with any ASCII textual content editor like textpad or notepad. I´ve noticed that many people are careworn approximately the abnormal filename. Well – really this document doesn´t actually have a call in any respect, it´s just an extended record call extension – .Htaccess. Hence, the DOT earlier than “htaccess” is NOT a type.

To create a .Htaccess record, truely open a new clean document in your preferred textual content editor and shop the file as .Htaccess. Some textual content editors (like notepad) do not help the Unix document layout and therefore you won´t be capable of store a record with the “.Htaccess” extension only. In this situation you can absolutely shop the record as 1.Htaccess or htaccess.Txt and later (after you've got uploaded it on your server) rename it to .Htaccess thru your FTP customer.

File Maker Tutorial
Question five. How To Define Custom Error Pages Using .Htaccess?

Answer :

You can define your personal blunders pages to enhance the communique along with your site visitors in case some thing´s wrong together with your website online or if they're trying to get admission to pages which might be now not to be had. Simply create a web site for each of the error codes you like.

Here are some of the maximum commonplace errors:

401 – Authorization Required – happens when users try and get admission to password covered pages with out giving the precise credentials.

403 – Forbidden – occurs when users attempt to get right of entry to a file (internet report, script, photograph, and so forth …) whose file permissions do now not permit the requested movement (execute / study / write).

404 – Not Found – takes place when users try to access a web site that doesn´t exist on your site.

500 – Internal Server Error.

You can name those custom mistakes pages some thing you want, however I suggest you pick out report names that remind you of the function of each report (f.Ex. Notfound.Html or 404.Html for the 404 blunders web page) and you can save them in any vicinity to your server that has net get right of entry to (either your root directory or a subdirectory). Then you can outline these pages as custom blunders pages to your .Htaccess record.

Supposing you have got named your mistakes pages 401.Html, 404.Html and 500.Html and stored them for your internet site´s root directory, you then could add these strains for your .Htaccess document:

ErrorDocument 401 /401.Html

ErrorDocument 404 /404.Html

ErrorDocument 500 /500.Html

If you've got named those pages “notfound.Html”, “authorization.Html” and “internalerror.Html” and uploaded them to a subdirectory named “errorpages”, you'll add this on your .Htaccess report:

ErrorDocument 401 /errorpages/authorization.Html

ErrorDocument 404 /errorpages/notfound.Html

ErrorDocument 500 /errorpages/internalerror.Html

PHP Interview Questions
Question 6. How To Enable Ssi On Static Webpages (.Html And .Htm) Using .Htaccess?

Answer :

SSI (server aspect consists of) provide a very bendy and smooth way to update the content material and fashion of positive elements (footer, header, sidebars, menus, ad blocks) of all your webpages by editing a single record best. To examine more approximately SSI, study the SSI academic.

To allow SSI on static .Html and .Htm webpages, you need to feature the following line in your .Htaccess report. Please be aware that this most effective works if your webhost helps SSI.

Question 7. How To Enable Php Parsing On Static Webpages (.Html And .Htm) Using .Htaccess?

Answer :

If you want to execute dynamic PHP code on otherwise static .Html and .Htm webpages, you want to allow PHP parsing on this form of web site. To try this, absolutely upload the subsequent line to your .Htaccess document after which you can include PHP code without delay within the supply code of your .Html and .Htm webpages. Make certain that you embed all PHP code interior starting and closing PHP tags (<?Php and ?>).

AddType application/x-httpd-Hypertext Preprocessor .Html .Htm

Please observe which you cannot use SSI and PHP parsing at the identical time. But don´t fear: you could encompass PHP code in SSI enabled webpages, too. For this purpose you'll need to stick the PHP code right into a clean textual content record, save the file as whateveryoulike.Hypertext Preprocessor, add it on your server after which consist of it with SSI:

<!–#include virtual=”path-to/whateveryoulike.Php” –>

PHP Tutorial MySQL Interview Questions
Question 8. How To Ban Certain Ip Addresses From Accessing Your Site Using .Htaccess?

Answer :

Whatever the motives are, sometimes you could need to ban sure IP addresses from gaining access to your website(s). This can easily be achieved by means of adding the subsequent lines in your .

Htaccess report (update IP with the IP address you want to prohibit from getting access to your website online, f.Ex.

order permit,deny
deny from IP
permit from all
Of course, you could specify more than one IP addresses and additionally C or B class IPs – this manner you will ban all IPs from the complete magnificence. F.Ex. Deny from a hundred twenty five.30.5. Would ban all of the IPs that start with 125.30.Five. (one hundred twenty five.30.Five.1, a hundred twenty five.30.Five.2, and so on …).

Add one IP in line with line on your .Htaccess record like this:

order permit,deny
deny from one hundred twenty five.30.5.1
deny from 125.30.Five.
Permit from all
Question 9. How To Protect Password Of Individual Directories On Your Site Using .Htaccess?

Answer :

If you're offering downloads out of your web page, you may need to area these right into a subdirectory of your website and protect it with a password which will save you the downloads from unauthorized get admission to. This manner, you could permit access simplest for registered contributors or for your publication subscribers and additionally trade the password once in a while.

Most webhosts provide this password protection function at once of their manage panels, so I advise you log into your manipulate panel and define usernames and passwords for the directories that you need to shield there, due to the fact this calls for greater than just modifying the .Htaccess record.

File internet Interview Questions
Question 10. How To Redirect Http To Https?

Answer :

RewriteEngine on
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R=301,L]
MySQL Tutorial
Question eleven. How To Redirect Http:// To Https://www?

Answer :

RewriteEngine on
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://www.%HTTP_HOST/$1 [R=301,L]
Internet Interview Questions
Question 12. How To Redirect Non-www To Www ?

Answer :

RewriteEngine On
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ http://www.%HTTP_HOST/$1 [R=301,L]
File Maker Interview Questions
Question thirteen. How To Redirect All Pages To Newdomain?

Answer :

RewriteEngine On

RewriteBase /
RewriteCond %HTTP_HOST !^olddomain.Com$ [NC]
RewriteRule ^(.*)$ http://newdomain.Com [R=301,L]
Internet Protocol model four (IPv4) Tutorial
Question 14. What Is Meaning Of R & L Flag In Htaccess?

Answer :

htacces R flag reasons a HTTP redirect to be issued to the browser and 301 manner its everlasting redirect.
Htaccess L fag reasons to prevent processing the guideline set, if the rule matches, no further policies can be processed.
Also we are able to set extra than 2 flags in brackets []
More flags
Question 15. How To Redirect Homepage To Another Website?

Answer :

Redirect / http://www.Net-technology-experts-notes.In/

Internet Protocol model four (IPv4) Interview Questions
Question 16. How To Redirect To Another Directory Within Same Domain?

Answer :

Redirect /olddir /newdir

CSS Advanced Tutorial
Question 17. How To Set Environment In .Htaccess?

Answer :

SetEnv APPLICATION_ENV improvement

CSS Advanced Interview Questions
Question 18. How To Set The Php Config Variables In .Htaccess?

Answer :

php_value upload_max_filesize 32M

PHP Interview Questions
Question 19. How To Set Display_error Off In .Htaccess?

Answer :

php_flag display_errors off

php_flag display_startup_errors off

HTTP Tutorial
Question 20. How To Block Few Ip Address?

Answer :

order allow,deny

deny from xxx.Xxx.Xxx.Xxx #specify a specific deal with

allow from all

Java Abstraction Interview Questions
Question 21. How To Redirect To Error/404.Html When 404 Errors Comes?

Answer :

ErrorDocument 400 error/404.Html

Question 22. How To Set The Caching For Javascript/pix/css?

Answer :

ExpiresActive On

ExpiresByType utility/javascript "now plus three day"

ExpiresByType software/x-javascript "now plus three day"

ExpiresByType image/jpg "now plus 1 week"

ExpiresByType picture/jpeg "now plus 1 week"

ExpiresByType photo/png "now plus 1 week"

ExpiresByType image/pjpeg "now plus 1 week"

ExpiresByType photograph/gif "now plus 1 week"

ExpiresByType text/css "now plus three day"

CodeIgniter Tutorial
Question 23. What Is Meaning Of 301, 302, 400, 401, 403, 404 And 500 Error Codes?

Answer :

301 - Permanent motion

302 - Temporary movement

400 - Bad request

401 - Authorization Required

403 - Forbidden

404 - Page Not Found

500 - Internal Server Error

HTTP Interview Questions
Question 24. How Does Rewritebase Works In .Htaccess?

Answer :

It is used to set a base URL on your rewrites rules.

RewriteEngine On

RewriteBase /~new/

By setting the RewriteBase there in htaccess, you are making the relative course come off the RewriteBase parameter.

MySQL Interview Questions
Question 25. How To Create Subdomains On The Fly Using .Htaccess?

Answer :

for this, you have set the virtual host

Follow the subsequent steps:

Step 1: Create a wildcard DNS entry

*.Domain.Com.   3600  A  127.Zero.0.1

Step 2: Setup the Virtual Host, in vhost document.

  DocumentRoot "E:wampwwwmyproject"

    ServerName myproject.Area.Com

   AllowOverride All

        Order allow,deny

        Allow from all

Step three: Now write your all codes in in Document Root path i.E.E:wampwwwmyproject

Step 4: Done, now you can access with myproject.Area.Com

Unix makefile Tutorial
Question 26. Do I Need To Restart The Apache After Changes In .Htaccess?

Answer :


CodeIgniter Interview Questions