Can somebody help me to redirect dispatcher url for below need?
to
https://localhost:8080/ca/en/abc/test (remove Group 1 - /content/mysite/home/ca/en/global/search-results, .html. ?, rootpath= Group 2 - /ca/en/abc¶m)
Views
Replies
Total Likes
Hi @Gatsby
1.Enable the mod_rewrite module in Apache.
2.Add the following rewrite rule to your Apache configuration file:
RewriteEngine On
RewriteRule ^/ca/en/global/search-results/rootpath=(.*)$ /content/mysite/home/ca/en/global/search-results.html?rootpath=$1 [L]
This rule will match any URL that starts with /ca/en/global/search-results/rootpath= and capture the value of rootpath as a group. It will then rewrite the URL to the original URL with the rootpath parameter set to the captured value.
3.Restart Apache to apply the changes.
## check if there is a rootpath query param with request
RewriteCond %{QUERY_STRING} ^rootpath=(.*)$
## rewrite the path with 302 redirect. If you don't want user to see the redirect, change R=302 with PT
RewriteRule ^/content/mysite/home/ca/en/global/search-results\.html$ /ca/en/global/search-results/rootpath/%1 [R=302,L] ## %1 captures the value of the query string. If you don't need it just replace it with "test" as per your usecase.
Thanks,
Lokesh
@Gatsby Is not the URL path not matching with the "/content/mysite/home/ca/en/global/search-results.html"?
Please check the Request URL path and update the RewriteRule to match with the path.
Some how I can able to achieve the part of my requirement as below:
RewriteCond %{QUERY_STRING} ^rootpath=(.*)¶m=(.*) [NC]
RewriteRule ^(.*) %1/%2 [R302,L]
However, I don't want this part in above URL
You can use QSD flag in rewrite rule to achieve this
https://httpd.apache.org/docs/trunk/rewrite/flags.html#flag_qsd
@arunpatidar @AMANATH_ULLAH There is 404 after using below rule
RewriteCond %{QUERY_STRING} ^rootpath=([^&]+)¶m=(.*)$
RewriteRule ^(.*) %1/%2 [R=302,L,QSD]
@Gatsby Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
@Gatsby If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes