I configed the vanity_urls in the dispatcher.
/vanity_urls {
/url "/libs/granite/dispatcher/content/vanityUrls.html"
/file "/tmp/vanity_urls"
/delay 300
}
The values of the /libs/granite/dispatcher/content/vanityUrls.html are
test1
test2
test3
In the AEM, the vanity url maps are
test1 mysite/home
test2 mysite/about
test3 mysite/product
Now, If I enter the https://docker.demo.com/test1, it will redirect to the https://docker.demo.com/mysite/home.
But If I enter the https://docker.demo.com/TEST1, I will get a 404 error.
Expected:
If I enter the https://docker.demo.com/TEST1, it would first convert to the https://docker.demo.com/test1, and then redirect to the https://docker.demo.com/mysite/home.
If I enter the https://docker.demo.com/TEST6, since test6 is not in the vanity_urls, so it will direct to the https://docker.demo.com/TEST6 and not convert it to lowcase.
Does anyone know how to achieve it?
BTW : I configed the ErrorDocument in the apache. If a page is not found, it will redirect to the error page. So I can't change the 404.jsp of error handle (sling\servlet\errorhandler) to achiece it.
ErrorDocument 404 /home/errors/404.html
Thanks,
Forrest
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @ForrestLi
Please add the below rule in your v-host file and the case related issue will be resolved.
##Rule to ignore case
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^(.*)[A-Z]+(.*)$
RewriteCond %{REQUEST_URI} !.*\..*$
RewriteRule (.*) ${lc:$1} [R=301,L]
Hope this helps!
Thanks
Hi @ForrestLi
Refer this article for case insensitive urls setup on dispatcher: https://blogs.perficient.com/2017/10/17/mastering-the-aem-dispatcher-part-2-case-insensitive-urls/
Thanks
Dipti
I checked that articel. Enable mod_speling will cause some unexpected error for me. The RewriteMap is not work for vanity url. That article can’t achieve my requirement.
Thanks,
Forrest
Views
Replies
Total Likes
Hi @ForrestLi
Please add the below rule in your v-host file and the case related issue will be resolved.
##Rule to ignore case
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^(.*)[A-Z]+(.*)$
RewriteCond %{REQUEST_URI} !.*\..*$
RewriteRule (.*) ${lc:$1} [R=301,L]
Hope this helps!
Thanks
This can achieve my requirement. But it will prevent me from accessing pages that contain capital letters (e.g. https://docker.demo.com/TEST6).
Thanks,
Forrest
Views
Replies
Total Likes
Hi @ForrestLi
As per the SEO Practice, all the URLs should be in lower case.
So if you use the above rule, all the URLs will be forcefully converted into lower case and then the request will be sent to publish instance to get the resource.
If your request URL is https://docker.demo.com/TEST6 then it will convert into https://docker.demo.com/test6 and then resolve the content. If you have the page in publish available with name as test6 then it will resolve and should not be an issue for you.
If still you want to retain few URLs in Upper case and do not want to convert into Lower case then use the below rule and exclude the specific URLs. You can use any specific pattern also to skip any specfic path exclusion.
##Rule to ignore case
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^(.*)[A-Z]+(.*)$
RewriteCond %{REQUEST_URI} !.*\..*$
RewriteCond %{REQUEST_URI} !^/TEST6
RewriteRule (.*) ${lc:$1} [R=301,L]
Thanks!
Views
Replies
Total Likes
Hi @ForrestLi ,
When you migrate from a legacy system, you’ll usually get a list of legacy vanity URLs and legacy URLs which need redirects. Apache httpd’s redirect maps make this an easy process, but like everything else in Apache, they are case sensitive.
So how do we work around this? There is a built-in redirect map in Apache which lowercases whatever it receives. We can use this to first downcase the URL, then check for it in the redirect map.
RewriteMap map.legacy txt:/etc/httpd/conf.d/map-legacy.txt RewriteMap lc int:tolower RewriteCond ${map.legacy:${lc:$1}} !="" RewriteRule ^(.*)$ ${map.legacy:${lc:$1}|/} [L,R=301]
You will also need to lowercase the redirect source URLs so they will match, for example:
/vanity1 https://www.site.com/afolder/apage.html /vanity2 https://apps.asite.com/An-App/In-IIS.aspx
Or else try :
RewriteEngine onRewriteBase / RewriteMap lowercase int:tolowerRewriteCond $1 [A-Z] RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]
Hope it helps!!
Thanks
Hi @Bimmi_Soi
I need to lowcase source url of vanity URLs instead of the legacy URLs. This does not achieve my requirement.
Thanks,
Forrest
Views
Replies
Total Likes
Can you please try to rewrite your url as below
RewriteEngine onRewriteBase / RewriteMap lowercase int:tolowerRewriteCond $1 [A-Z] RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]
Hope this helps.
Thanks
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies