Highlighted

Vanity url is not working with rewrite rule

Anderson_Hamer

21-08-2020

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?

Replies

Highlighted

Albin_Issac

MVP

21-08-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

Highlighted

Singaiah_Chintalapudi

MVP

21-08-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.

Highlighted

Anderson_Hamer

24-08-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 ?