smaller reset larger         

Main Menu

All times are in GMT -7 (DST) :: The time is now 12:31 pm.

Sub Menu

Category Details
Category Name
.htaccess
Category Created
Wed, 23rd Mar 2011
Last Article Update
Mon, 20th Feb 2012
Category Actions
 
(Lost?)

   .htaccess

404 error "No input file specified" PHP CGI 

When running PHP as a CGI Binary and not in library mode, Apache will send any PHP based request directly to the php executable without verifying if the request is valid. This can cause seemingly random errors such as the 'No input file specified' message. The good news is that this is easily resolved by using an .htaccess directive.

Here is the code that you will want to use to resolve this issue,

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^.+\.php$ /junkfile
 

This code will work so long as you do not have a file called 'junkfile' in your default content tree.

View Full Article Add Comment

500 Error on Website 

500 errors occur when you tell the server to do something that it will not or cannot do.

Generally 500 errors occur due to bad .htaccess directives and/or syntax. 

The way to fix this is to look through any .htaccess files in directories that are generating the 500 error and fix any bad code. If you've made recent changes, reverse those changes and try again. If this doesn't solve the problem be sure to clear you browser cache and try once more. This can typically be done by pressing Ctrl + F5 on your keyboard.

View Full Article Add Comment

Create an .htaccess file using the QWK.net editor 

  1. Go to customers.qwk.net, click on account management and log in.
  2. Click the FTP Manager icon.
  3. Click the green door that says login.
  4. Click the directory in which you wish to create the file.
  5. At the top of the file manager click "File" it is the second button from the right next to trash.
  6. In the field labeled "Text Editor" Change the filename to whatever you will need it to be i.e. .htaccess
  7. Enter any text in the large box below and click "Save".
  8. Your file is created.

 

View Full Article

Creating an .htaccess file 

 .htaccess files are text files that contain instructions for the server. Some typical uses of .htaccess files include rewriting URLs for search engine optimization, and preventing certain users from accessing your website. More information about .htaccess files can be found here. This is a link to the actual .htaccess site.

1. Open a text editor of your choice. (Microsoft Word cannot be used, the most common substitutes are Textedit for MacOS, or vi or vim on Linux.  If you are a windows based user you will want to create the file using the file creator on your QWK.net control panel, Instructions can be found here.)

2. Create a file named htaccess.txt.

  • The reason we do not name it .htaccess right away is that many operating systems will automatically hide .htaccess files.

3. Now that you have the file itself created you can add directives or simply upload it to your FTP account for later use.

  • Uploading the file may be done using any FTP application or even using the built in FTP client in your QWK.net Shared Hosting account

4. Once your htaccess.txt file is uploaded to the server you will need to rename it to .htaccess, from here it should begin working immediately.

View Full Article Add Comment

Custom 404 pages 

Utilizing a .htaccess file we can tell our website how to go about showing custom 404 pages.

Adding this line to .htaccess will tell the server what to do when a 404 error hits.

ErrorDocument 404 /404.html

You can make the 404.html whatever file you would like (for example you can make it error.html instead).

Insde the file you can do whatever HTML you would like, you can redirect to your sites homepage for example.

For information on creating .htaccess files see this article

View Full Article Add Comment

Force https for use with SSL certificates 

To do this we will utilize the mod_rewrite engine allowed on Qwk.net servers through the use of .htaccess

First thing we need to do is turn the rewrite engine on

RewriteEngine On

Now we need a rule that will trigger the switch to https:

RewriteCond %{SERVER_PORT} 80 

What this condition does is look for all traffic that is coming in on port 80, port 80 is the standard traffic port for all http traffic. When it sees port 80 traffic it will trigger and execute the nex command below it.

Now that we have a condition to capture non https traffic, we need to rewrite the URL to switch to https

RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Switching out "yourdomain" here with your actual domain name will cause the url to be rewritten from its http format to one with https.

The above example will switch the entire site over to https, but what if you want to just switch a specific directory over, say one that is a checkout for an ecommerce site?

All we need to do is add an extra condition to test for when Users are in a directory that needs to be forced to SSL.

RewriteCond %{REQUEST_URI} securefolder

Change "securefolder" to the directory you wish to use https on.

Now we alter the rewrite rule to change the directory.

RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Make sure that the folder name matches in both statements, or else complications may arise.

The finished product for a subfolder rewrite will look like this:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} securefolder
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

The finished product for securing the whole site will look like this:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
View Full Article Add Comment

Force URL to Display www 

Instances where this can be an issue is SSL certificates when the certificate is generated for the www.domain.com address. This fix is an .htaccess directive. If you need help creating and using .htaccess directives please refer to this article.

RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

  • To change this code to work for your website, change "domain" to your website's domain.
  • One thing to be aware of is that if the rewrite engine is constantly running it can degrade performance of your website. This code is best implimented in folders where it is critical to have the www. formatted address. Examples of this would be shopping carts or checkouts. 
View Full Article Add Comment

Magento Shopping Cart Images 

This issue is likely caused by a default setting in php.  Magento typically loads an .htaccess file when it installs.  If you will open that file and change the magic_quotes_gpc setting to "ON" then the application should allow you to load the images. 

View Full Article Add Comment

Magic Quotes 

Qwk.net Servers allow there users to run their own .htaccess files, which means that Users can enable magic quotes and a host of other things.

to enable magic quotes enter this line into your .htaccess file.

php_value magic_quotes_gpc 1

Make sure to enter a carriage return and then save the file to the directory web calender is in.

View Full Article Add Comment

Prevent Hotlinking of Files 

It is sometimes useful to prevent others from linking directly to pages or files contained within your site. You may, for example, want users to enter through your index page to see important announcements.
To enable this restriction, create an .htaccess file with the following contents in the directory you wish to protect:

AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/
RewriteCond %{HTTP_REFERER} !^http://domain.com/
RewriteCond %{HTTP_REFERER} !^http://www.otherdomain.com/
RewriteRule /* http://www.domain.com/index.html [R,L]

...where domain.com is your domain name, and http://www.otherdomain.com is another site you wish to except from the linking restriction. (You may duplicate this line to add other sites.)

View Full Article Add Comment

Remove Case Sensitivity for URLs 

Newer versions of Windows amd Linux will always recognize the case of a letter as two different letters, i.e. a capital 'A' is different than a lowercase 'a'. When a Windows or Linux machine is a webserver this rule also applies.  This goes for directories, usernames, passwords, etc.

One way to work around this rule is to always use lowercase. This isn't a solution but a habit for web development that allows interoperability

Another option is to use the following .htaccess directive. Adding this code to your .htaccess file will cause the server to scan all directories to find a match regardless of case and redirect the user to the target directory.

<IfModule mod_spelling.c>
CheckSpelling on
</IfModule>
  • This solution won't solve all capitalization problems but can do the job for most developers.
  • This solution can decrease server performance as it does have to scan every directory when it recieves a URL request.
View Full Article Add Comment

Website gives 403 error 

This is the mod_security apache firewall blocking your request.

The first and foremost thing to check is to make sure you are running the most recent install of Wordpress that is available. Many of the old versions have different security vulnerabilities and this may be what is generating the 403. 

If an update does not fix this issue you can install the following htaccess directive:

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

This is a last resort thing to do. Mod_security protects your site from many different kinds of attacks from hackers. Installing this does not mean you will be hacked, but it does open your site up a little bit.

View Full Article Add Comment

What is .htaccess 

 

.htaccess is a directory-level configuration file that is supported by QWK.net Shared hosting servers, it allows for decentralized management of your web server configuration.

 

 

View Full Article Add Comment

Referrer Filtering 

Here is an .htaccess directive that will allow you to filter requests to whatever sub-directory you put it in. This directive will also effectively stop any hotlinking to your site.

SetEnvIfNoCase Referer "^http://yourdomain\.com/" good_referer=1
order allow,deny
allow from env=good_referer
OnDeny http://yourdomain.com/warningpage.htm

  • In this example you are specifying yourdomain as the only referrer that can access the directory that this .htaccess directive is in.
  • 'http://yourdomain.com/warningpage.htm' is the path to your declined screen, you can set this to whatever you want.
  • If you need help creating or using an .htaccess file please refer to this article.
View Full Article Add Comment