1

I have looked through various other posts on here but I can't seem to find any that show how to do a redirect in HTACCESS if the url does NOT contain a specific string. What I need to do is force HTTPS/WWW to all requests unless the request is for appfeed.domain.com. In that case, I don't want to redirect at all but just let the request go through.

Here is what I have now.

RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

This works, but it also redirects my appfeed.domain.com requests to www.appfeed.domain.com, which obviously breaks the request. can anyone help me out here?

0

1 Answer 1

3

Could you please try following, written as per your shown samples. This will process requests only for for domain which is not appfeed.domain.com. Adding 1st condition as per of that and rest of the conditions from OP's htaccess itself.

RewriteEngine ON
RewriteCond %{HTTP_HOST} !appfeed\.domain\.com [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.