performance - 301 redirects Apache: It is better to do it in httpd.conf or in .htaccess? -


I'm planning to make adjustments to your website's URL for better SEO and server performance, which is a problem I like a lot of care

I do not want to overload the .htaccess file with several 301 redirects. Is it better to do it instead of .htaccess in httpd.conf?

The .htaccess file is read in every HTML request, however, the httpd.conf file only loads once the Apache starts. Is that right? If so, will this server performance load redirection rules be improved only once?

The HTAC file is not modified until it (depends on some extent on the host OS and filesystem ), So it is not being loaded for every request, however, the documentation of the APA says that the instructions in general are as fast as possible in the server / vhost configs as opposed to the instructions in the HTACAC file.

See:

In general, you should only use .htaccess files when you do not have access to the main server configuration file. For example, a common misconception is that user authentication should always be in .htaccess files, and, in recent years, there is another misconception that mod_rewrite instructions should go into .htaccess files. This is simply not the case. You can put user authentication configuration in main server configuration, and in fact, the preferred way of doing things is similar, in mod_rewrite instructions, main server configuration, in many cases, work better.

.htaccess files should be used in a situation where the content providers need to make configuration changes to the server on a per-directory basis, but there is no root access to the server system in such an event that The server administrator is not constantly ready to make configuration changes, for individual users to make these changes in .htaccess files for themselves. A permit may be desirable. This is especially true, for example, in cases where ISPs are hosting multiple user sites on the same machine, and want their users to change their configuration. However, in general, the use of .htaccess should be avoided whenever possible. Any configuration that you would consider putting in the .htaccess file, your main server can be effectively done in a section of the configuration file.

There are two main reasons to avoid using .htaccess files.

The first of these is the display when AllowOverride is set to allow the use of .htaccess files, httpd will appear in every directory for .htaccess files. Thus, allowing the .htaccess files to be a performance hit, even if you do not actually use them! Additionally, the .htaccess file is requested every time from a document.

Further note that httpd should look for .htaccess files in all top-level directories, so that the instructions should apply to get the full complement (see section on how instructions are implemented In this way, if a file is requested from a directory / www / htdocs / example, then httpd must look for the following files:

/ .htaccess / www / Htaccess /www/htdocs/.htaccess/www/htdocs/example/.htaccess/code/

And of course, To get out of that directory for a file, there are 4 additional file system access, even if none of those files exist (note that this will only happen when .htaccess files were enabled for / Which is not usually the case.)

In the case of RewriteRule instructions, in the .htaccess reference, these regular expressions should be re-found with every request for the directory, while the main server configuration In addition, they are compiled and cached once, in addition, the rules themselves are more complex, because someone should work around restrictions with per-directory references and mod_rewrite. Consult the rewrite guide for more information on this topic.

The second idea is one of security. You are allowing users to modify server configuration, which may result in you have no control. Carefully consider whether you want to give this privilege to your users. Also keep in mind that users will receive additional technical support requests by giving less privilege than their needs. Make sure you clearly tell your users how much privileges you have given them. Define exactly what you have allowed, allow, and pointing them in the related document, will later save yourself in a very confusing situation.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -