YouTube Icon

Interview Questions.

Top 26 Htaccess Interview Questions - Jul 25, 2022

fluid

Top 26 Htaccess Interview Questions

Q1. How To Create .Htaccess Files?

Creating a .Htaccess record may be very easy and may be accomplished with any ASCII text editor like textpad or notepad. I´ve observed that many people are harassed approximately the ordinary filename. Well – without a doubt this document doesn´t actually have a name at all, it´s simply an extended record name extension – .Htaccess. Hence, the DOT earlier than “htaccess” is NOT a type.

To create a .Htaccess record, truely open a brand new blank document in your favourite text editor and keep the record as .Htaccess. Some textual content editors (like notepad) do now not aid the Unix document format and therefore you received´t be able to save a record with the “.Htaccess” extension most effective. In this case you may virtually store the report as 1.Htaccess or htaccess.Txt and later (after you have uploaded it on your server) rename it to .Htaccess via your FTP patron.

Q2. How To Enable Ssi On Static Webpages (.Html And .Htm) Using .Htaccess?

SSI (server side includes) provide a totally flexible and clean way to update the content and style of sure parts (footer, header, sidebars, menus, advert blocks) of all of your webpages through enhancing a single record handiest. To analyze more about SSI, study the SSI educational.

To permit SSI on static .Html and .Htm webpages, you want to feature the subsequent line to your .Htaccess record. Please notice that this most effective works if your webhost helps SSI.

Q3. How To Redirect To Error/404.Html When 404 Errors Comes?

ErrorDocument 400 mistakes/404.Html

Q4. How To Redirect To Another Directory Within Same Domain?

Redirect /olddir /newdir

Q5. How To Set Environment In .Htaccess?

SetEnv APPLICATION_ENV development

Q6. How To Redirect Http:// To Https://www?

RewriteEngine on

RewriteCond %HTTPS off

RewriteRule ^(.*)$ https://www.%HTTP_HOST/$1 [R=301,L]

Q7. Do I Need To Restart The Apache After Changes In .Htaccess?

No

Q8. How To Redirect Http To Https?

RewriteEngine on

RewriteCond %HTTPS off

RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R=301,L]

Q9. How Does Rewritebase Works In .Htaccess?

It is used to set a base URL for your rewrites guidelines.

RewriteEngine On

RewriteBase /~new/

By putting the RewriteBase there in htaccess, you're making the relative course come off the RewriteBase parameter.

Q10. Why Do We Use This And Where?

Using this “.Htaccess” file, we can manipulate “Hypertext Preprocessor.Ini” and “httpd.Conf” report.

Q11. How To Protect Password Of Individual Directories On Your Site Using .Htaccess?

If you're offering downloads from your web page, you could want to location these right into a subdirectory of your website and shield it with a password if you want to save you the downloads from unauthorized get right of entry to. This way, you could allow access most effective for registered members or on your newsletter subscribers and also change the password now and again.

Most webhosts provide this password safety function immediately of their manage panels, so I suggest you log into your manage panel and outline usernames and passwords for the directories that you need to defend there, because this requires extra than simply enhancing the .Htaccess report.

Q12. What Is Meaning Of 301, 302, 400, 401, 403, 404 And 500 Error Codes?

301 - Permanent motion

302 - Temporary movement

four hundred - Bad request

401 - Authorization Required

403 - Forbidden

404 - Page Not Found

500 - Internal Server Error

Q13. How To Define Custom Error Pages Using .Htaccess?

You can define your personal error pages to enhance the conversation along with your traffic in case some thing´s incorrect with your website online or if they're looking to access pages which can be no longer available. Simply create a website for every of the mistake codes you want.

Here are a number of the most not unusual mistakes:

401 – Authorization Required – takes place whilst customers try and get admission to password covered pages without giving the perfect credentials.

403 – Forbidden – happens whilst customers try to access a file (net report, script, picture, and many others …) whose record permissions do now not allow the requested movement (execute / examine / write).

404 – Not Found – occurs whilst users try to get right of entry to a web site that doesn´t exist to your web page.

500 – Internal Server Error.

You can name these custom errors pages whatever you like, but I suggest you choose report names that remind you of the feature of each record (f.Ex. Notfound.Html or 404.Html for the 404 mistakes web page) and you may store them in any place for your server that has net get entry to (either your root directory or a subdirectory). Then you can outline those pages as custom mistakes pages on your .Htaccess record.

Supposing you have got named your error pages 401.Html, 404.Html and 500.Html and stored them to your website´s root listing, then you definitely might upload those strains for your .Htaccess document:

ErrorDocument 401 /401.Html

ErrorDocument 404 /404.Html

ErrorDocument 500 /500.Html

If you have got named those pages “notfound.Html”, “authorization.Html” and “internalerror.Html” and uploaded them to a subdirectory named “errorpages”, you'll upload this in your .Htaccess record:

ErrorDocument 401 /errorpages/authorization.Html

ErrorDocument 404 /errorpages/notfound.Html

ErrorDocument 500 /errorpages/internalerror.Html

Q14. How To Redirect Non-www To Www ?

RewriteEngine On

RewriteCond %HTTP_HOST !^www.

RewriteRule ^(.*)$ http://www.%HTTP_HOST/$1 [R=301,L]

Q15. How To Set Display_error Off In .Htaccess?

Php_flag display_errors off

php_flag display_startup_errors off

Q16. What Is Meaning Of R & L Flag In Htaccess?

Htacces R flag reasons a HTTP redirect to be issued to the browser and 301 me its everlasting redirect.

Htaccess L fag reasons to forestall processing the guideline set, if the guideline matches, no similarly guidelines may be processed.

Also we can set more than 2 flags in brackets []

More flags

Q17. How To Create Subdomains On The Fly Using .Htaccess?

For this, you have set the digital host

Follow the subsequent steps:

Step 1: Create a wildcard DNS entry

*.Area.Com.   3600  A  127.Zero.Zero.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 direction i.E.E:wampwwwmyproject

Step 4: Done, now you could access with myproject.Domain.Com

Q18. How To Redirect All Pages To Newdomain?

RewriteEngine On

RewriteBase /

RewriteCond %HTTP_HOST !^olddomain.Com$ [NC]

RewriteRule ^(.*)$ http://newdomain.Com [R=301,L]

Q19. How To Ban Certain Ip Addresses From Accessing Your Site Using .Htaccess?

Whatever the reasons are, from time to time you may need to prohibit certain IP addresses from accessing your internet site(s). This can without difficulty be finished through including the subsequent strains to your .

Htaccess file (replace IP with the IP address you want to ban from getting access to your site, f.Ex. 123.33.Sixty four.1):

order allow,deny

deny from IP

permit from all

Of direction, you can specify multiple IP addresses and also C or B class IPs – this manner you'll ban all IPs from the entire magnificence. F.Ex. Deny from 125.30.@might ban all the IPs that begin with one hundred twenty five.30.@(125.30.5.1, one hundred twenty five.30.Five.2, and so forth …).

Add one IP in step with line to your .Htaccess file like this:

order permit,deny

deny from 125.30.5.1

deny from one hundred twenty five.30.@

permit from all

Q20. How To Redirect Homepage To Another Website?

Redirect / http://www.Net-era-professionals-notes.In/

Q21. What Can Be Done With .Htaccess File?

Some examples of what can be carried out with a .Htaccess report. They are all included in this educational:

Define custom blunders pages

Banning certain IP addresses from having access to your website online

redirecting users to other pages / websites

password protecting directories

permitting positive PHP modules

permitting SSI (server facet includes)

Q22. How To Set The Php Config Variables In .Htaccess?

Php_value upload_max_filesize 32M

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

If you want to execute dynamic PHP code on otherwise static .Html and .Htm webpages, you need to allow PHP parsing in this type of webpage. To do that, clearly add the following line in your .Htaccess record and then you could encompass PHP code immediately inside the source code of your .Html and .Htm webpages. Make positive that you embed all PHP code interior starting and ultimate PHP tags (<?Php and ?>).

AddType software/x-httpd-php .Html .Htm

Please notice that you can't use SSI and PHP parsing on the identical time. But don´t worry: you may consist of PHP code in SSI enabled webpages, too. For this reason you'll need to stick the PHP code right into a clean textual content record, store the document as whateveryoulike.Personal home page, upload it on your server and then include it with SSI:

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

Q24. How To Set The Caching For Javascript/pics/css?

ExpiresActive On

ExpiresByType application/javascript "now plus three day"

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

ExpiresByType photo/jpg "now plus 1 week"

ExpiresByType picture/jpeg "now plus 1 week"

ExpiresByType photo/png "now plus 1 week"

ExpiresByType photograph/pjpeg "now plus 1 week"

ExpiresByType photo/gif "now plus 1 week"

ExpiresByType text/css "now plus 3 day"

Q25. What Is .Htaccess?

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

Q26. How To Block Few Ip Address?

Order permit,deny

deny from xxx.Xxx.Xxx.Xxx #specify a selected cope with

permit from all




CFG