Welcome to Web Hosting Forum - Net Hosting Talk

Register now and be part of our community! When you register with the Net Hosting Talk you can join in with topics, start new topics, and generally be a part of the first level of our community. It's also quick and totally free, so what are you waiting for?

Rewrite url multiple condition

rigsby

Newbie
Messages
18
Reaction score
0
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.
 

geniushost 

Premium Member
Messages
33
Reaction score
1
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

Top