Web Hosting Forum - Explore the Latest in Web Hosting Discussions

We are a community of individuals and businesses passionate about web hosting. Let's build, learn, and grow together.

Rewrite url multiple condition

rigsby

Novice
Member
Hello, 

I have a little problem that I can not solve, and that poses me a big problem. I applied on all my sites, a rule allowing me to add a / at the end of the url:
Code:
# ADD SLASH END URL 
RewriteCond  % {REQUEST_URI} (/[^.*+)[^/]$
RewriteRule ^ (. *) $ Http: // % {HTTP_HOST} % {REQUEST_URI} / [R = 307 , L]

It works perfectly, but I encounter a problem when renewing my SSL certificates, the / added prevents me automatic renewal and requires me to remove this rule renewal time. I am therefore looking to add a condition to this rule, so that it does not apply during a renewal. 

For this, I identified the type of url to rule out in the rule, it comes in this form: http://domain.com/.well-known/acme-challenge/

order to to have something like this: 

If by slash at the end of url (% {REQUEST_URI} (/[^.]+)[^/]$) [OR] 
If the url is not of the type http: / /domain.com/.well-known/acme-challenge/(.*)
Then applied the rule ^ (. *) $ Http: //% {HTTP_HOST}% {REQUEST_URI} / [R = 307, L] 

How can I set this condition? 
I do not hide from you that I do not master this kind of thing at all, I have identified the flag [OR] to add a condition, but I can not write it. 

Thank you in advance for your help.
 
  • Advertisement
  • Hello,

    Try this
    Code:
    RewriteCond  % {REQUEST_URI} (/[^.]+)[^/]$ [OR]
    RewriteCond  % {REQUEST_URI} ! ^ /. Well-known / acme-challenge /(.*)$
    RewriteRule ^ (. *) $ http: // % {HTTP_HOST} % {REQUEST_URI} / [R = 307 , L]


    Regards :)
     
  • Advertisement
  • Advertisement

    Back
    Top