Asked by:
Rewrite dynamic URL

Question
-
User-1165198546 posted
Hello everybody,
I have a URL like this:
https://examplesite.com/page/?photo=wedding&=Milan
how can I transform it by removing from URL the ?, =, &, characters so that it becomes like this?
https://examplesite.com/page/photo-wedding-MilanI'm not very familiar with the rewrite rule, so an example of the code would be much appreciated!
Thank youTuesday, May 11, 2021 9:40 AM
All replies
-
User1065476709 posted
Hi Jeymax,
https://examplesite.com/page/?photo=wedding&=Milan
how can I transform it by removing from URL the ?, =, &, characters so that it becomes like this?
https://examplesite.com/page/photo-wedding-MilanYou can try this rule:
<rule name="test" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{REQUEST_URI}" pattern="^/page/\?photo=wedding&=Milan" /> </conditions> <action type="Redirect" url="page/photo-wedding-Milan" /> </rule>
Best regards,
Sam
Wednesday, May 12, 2021 2:51 AM -
User-1165198546 posted
<rule name="test" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{REQUEST_URI}" pattern="^/page/\?photo=wedding&=Milan" /> </conditions> <action type="Redirect" url="page/photo-wedding-Milan" /> </rule>
Hi Samwu,
thanks for your reply.
In which file should this code be placed?
.htaccess?
functions.php?
other?
Finally a last question?
is it possible to apply this rule to dynamic urls? like:
https://examplesite.com/page/?photo=custom-post-type&=taxynomyin https://examplesite.com/page/photo-custom-post-type-taxynomy
or do I have to do it for each URL?
thank you so muchWednesday, May 12, 2021 8:56 AM -
User1065476709 posted
Hi Jeymax,
In which file should this code be placed?
.htaccess?
functions.php?
other?
You need place it in url rewrite.
Creating Rewrite Rules for the URL Rewrite Module
is it possible to apply this rule to dynamic urls? like:
https://examplesite.com/page/?photo=custom-post-type&=taxynomyin https://examplesite.com/page/photo-custom-post-type-taxynomy
Usually yes, but your needs are a bit special, so you need to create rules for each URL.
Best regards,
Sam
Thursday, May 13, 2021 6:52 AM -
User960727790 posted
Jeymax
Hello everybody,
I have a URL like this:
https://examplesite.com/page/?photo=wedding&=Milan
how can I transform it by removing from URL the ?, =, &, characters so that it becomes like this?
https://examplesite.com/page/photo-wedding-MilanI'm not very familiar with the rewrite rule, so an example of the code would be much appreciated!
Thank youI was also having a lot of issues regarding this since I am just starting out. being frustrated i finally decided to get some professional help from eduhelphub, they got good tutorials and stuff that can give a good head start
Friday, May 21, 2021 5:26 PM