Rewrite url multiple condition

Our discussions on Web Hosting that will tell you everything you need to know. Find advice, questions and answers on the who's, what's, when's and where's of the Web Hosting world.
Post Reply
rigsby
Newbie
Posts: 9
Joined: Fri Sep 29, 2017 8:56 am

Tue Feb 20, 2018 2:16 pm

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: Select all

# 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.


User avatar
geniushost
Junior Member
Posts: 22
Joined: Mon Nov 13, 2017 1:34 pm

Tue Feb 20, 2018 3:49 pm

Hello,

Try this

Code: Select all

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

Regards :)
rigsby
Newbie
Posts: 9
Joined: Fri Sep 29, 2017 8:56 am

Tue Feb 20, 2018 4:13 pm

its working. this is what i was looking for. thank you for help :)
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests