Expand my Community achievements bar.

SOLVED

Facing Issue with rewrite rule asked by our client

Avatar

Level 1

Hello,

Our client has asked us to make a rewrite rule of this style

 

RewriteRule ^ /text/text/text/text-text-text-text-i%21$ https://%{HTTP_HOST}/text [L,R=301]

 

However i can not seem to get it to work, i am guessing it is because the special character, but i am not finding a solution.

I have already tried adding NE in the rules.

 

Any insight i can receive on this? I have other similar requests that i do not know how to approach either.

Like this one

 

RewriteRule ^ /text/text/text/%20?date=20190808$ https://%{HTTP_HOST}/text [L,R=301]

 

Thanks in Advance for any help provided


Best Regards.

1 Accepted Solution

Avatar

Correct answer by
Level 5

It would have been helpful if you provided the exact use case. But with the two examples which you have provided, it could be done something like 

RewriteRule ^/text/(.*)$ https://%{HTTP_HOST}/text [L,R=301]

View solution in original post

3 Replies

Avatar

Correct answer by
Level 5

It would have been helpful if you provided the exact use case. But with the two examples which you have provided, it could be done something like 

RewriteRule ^/text/(.*)$ https://%{HTTP_HOST}/text [L,R=301]

Avatar

Community Advisor

Hi @DanielMa16 
If you are looking for anything generic then you may need to something like below

# Generalized rewrite rule for repeated word pattern

RewriteRule ^(.+)/\1/\1/\1-\1-\1-\1-i%21$ /$1 [R=301,L]



Arun Patidar

Avatar

Level 1

Hello @arunpatidar 

in this case i could get by with @h_kataria answer, but i would save your advice for another more generalized case i may encounter in the future.

Thank you so much to both of you.

Best Regards.