BreadCrumbs: Apache

Apache

From Luke Jackson

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:16, 15 August 2007 (edit)
Ljackson (Talk | contribs)
(How to redirect HTTP to HTTPS using mod_rewrite.)
← Previous diff
Revision as of 03:17, 15 August 2007 (edit)
Ljackson (Talk | contribs)
(How to redirect HTTP to HTTPS using mod_rewrite.)
Next diff →
Line 17: Line 17:
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [L,R] RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [L,R]
-Remember, if you put this rule in the main server configuration file (usually httpd.conf) rather than an .htaccess file, you'll need to use '''^/''' instead of '''^''' at the beginning of the RewriteRule line. Because of this there are two code snippets above, one for httpd.conf and one for .htaccces.+Remember, if you put this rule in the main server configuration file (usually httpd.conf) rather than an .htaccess file, you'll need to use '''"^/"''' instead of '''"^"''' at the beginning of the RewriteRule line. Because of this there are two code snippets above, one for httpd.conf and one for .htaccces.
=== How do I change the length of the URLs generated by mod_autoindex? === === How do I change the length of the URLs generated by mod_autoindex? ===

Revision as of 03:17, 15 August 2007

Contents

FAQs

How to redirect HTTP to HTTPS using mod_rewrite.

The following configuration will configure Apache to automatically redirect HTTP requests to HTTPS, i.e. http://www.website.com to https://www.website.com.

httpd.conf:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]

.htaccess:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [L,R]

Remember, if you put this rule in the main server configuration file (usually httpd.conf) rather than an .htaccess file, you'll need to use "^/" instead of "^" at the beginning of the RewriteRule line. Because of this there are two code snippets above, one for httpd.conf and one for .htaccces.

How do I change the length of the URLs generated by mod_autoindex?

The NameWidth keyword allows you to specify the width of the filename column in bytes.

  • -NameWidth (or unset) allows mod_autoindex to calculate the best width.
  • NameWidth=n fixes the column width to n bytes wide.
  • NameWidth=* grows the column to the necessary width.

Below is an example on how to edit your httpd.conf file to enable unlimited characters:

# IndexOptions: Controls the appearance of server-generated directory
# listings.
#
IndexOptions FancyIndexing VersionSort NameWidth=*

(13)Permission denied: /www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

This can range in exact location but at the core it is a permissions issue.

  • While child directories of the DocumentRoot can have a permission value of 744 the DocumentRoot needs to have a permission of 755.
  • Ensure all .htaccess files have a permission of 755
chmod -R 755 <dir_or_file(s)>

Access forbidden! You don't have access to the requested directory...

There is either no index document or the directory is read-protected.

Allow Directory Listing

  • Create .htaccess file in the affected directory and copy the text below into the file.
Options FollowSymLinks ExecCGI Indexes

Create DirectoryIndex File

  • Determine Allowable DirectoryIndex extensions from the DirectoryIndex line in your httpd.conf file.
  • Create an empty file in the affected directory.
touch index.htm
Personal tools