Vanity url is not working with rewrite rule | Community
Skip to main content
Anderson_Hamer
Level 4
August 21, 2020

Vanity url is not working with rewrite rule

  • August 21, 2020
  • 2 replies
  • 3417 views

We are trying to make the vanity url works on both publish and dispatcher servers.  Download and installed the VanityURLS-Components package and followed all the steps that documented.

 

The vanity url is working only when we delete or comment the below rewrite rule

  RewriteCond %{REQUEST_URI} !^/apps

  RewriteCond %{REQUEST_URI} !^/bin

  RewriteCond %{REQUEST_URI} !^/content

  RewriteCond %{REQUEST_URI} !^/etc

  RewriteCond %{REQUEST_URI} !^/home

  RewriteCond %{REQUEST_URI} !^/libs

  RewriteCond %{REQUEST_URI} !^/tmp

  RewriteCond %{REQUEST_URI} !^/var

  #RewriteRule ^/(.*)$ /content/myproject/$1 [PT,L]

 

But the above commented rewrite rule is required to allow only /content path. Dispatcher filter will reject any request that is not started with /content. With that even etc sling mapping also could not help because the request is not blocked at dispatcher level and not reached publish server.

Is there any other way to handle this without removing rewrite rule?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Community Advisor
August 21, 2020

One option I can think of is always enable the vanity URL in AEM by appending the full content URL(append the hided path) .e.g append /content/myproject(/content/myproject/vainity1) to enable the vanity path /vanity1(https://www.example.com/vanity1). The [PT] rule defined by you in the Apache always append /content/myproject for your vanity URL's (/content/myproject/vanity) so the AEM server match the right vanity defined(/content/myproject/vanity1)

If you follow this option, the VanityURLS-Components configurations are not required - these configurations are enabled only to whitelist the vanity paths in the farm filter.

Regards

Albin I

www.albinsblog.com

Singaiah_Chintalapudi
Level 7
August 21, 2020

 

First of all, the above snippet is used to append the /content/myproject/* path to your incoming shortened urls. Ex: www.example.com/mypage.html would resolve to: server:port/content/myproject/en/mypage.html. The highlighted part would vary based on project implementation. All other urls would go publish server unless you're blocking them at dispatcher filters.

 

You can use RewriteRule to redirect your vanity to AEM URLs. 

 

Whats your exact specific use case? You don't need the vanity urls package.

narendragandhi
Community Advisor
Community Advisor
August 21, 2020

Hi @anderson_hamer ,

 

You could use the /vanity_urls filter to enable the auto filtering for all vanity URLs. Here is the article you could refer to configure this - https://helpx.adobe.com/experience-manager/kb/ams-dispatcher-manual/disp-vanity-url.html

 

 

Anderson_Hamer
Level 4
August 24, 2020

Yeah but this /vanity_urls filter is not the filtering the vanity URLs that get stored in /temp/vanity_urls file. I could see the vanityURLS in {dispurl}/libs/granite/dispatcher/content/vanityUrls.html

 

What happens here is, if I hit the vanity URL like - {dispURL}/vanity1, then rewrite rule comes into picture and it is adding /content/myproject/vanity1 and sending a request to publisher, getting 404 page as there is no such page in pub server.

 

The dispatcher would want to send the same request as vanity like {dispaURL}/vanity1 to pub server then the pub will resolve the url resource and it will server the request. Is there any other way to do this ?

March 6, 2024

Hi @anderson_hamer were you able to resolve this issue? 2024 and I'm facing the same situation.