Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to change this so that one file in wp-admin is not forced through https:

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ https://%{SERVER_NAME}/$1/ [R=301,L]

This forces all requests to /wp-admin through SSL but it is breaking a wordpress plugin which needs to access wp-admin/admin-ajax.php.

Is there a way to adjust the rule so that it will allow non encrypted requests to that one file?


share|improve this question

Have not tested it, but this should do it...

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
Redirect /directory/file.html http://domain.com/directory/file.html
share|improve this answer
thats for a folder. Will it work for a specific file URL? ALso, wouln't it be RewriteCond %{REQUEST_URI} ^.*/somefolder$ ? – codecowboy Nov 2 '10 at 15:24
@codecowboy - Sorry, I was under the understanding you wanted it done for the entire directory. I have modified my answer. – Jeremy Nov 2 '10 at 15:47

Add an additional condition before your rule that does the redirect to https:

RewriteCond %{REQUEST_URI} !=/wp-admin/admin-ajax.php

Which will prevent the rewrite/redirect from occuring for this file

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.