Expand my Community achievements bar.

Vanity url is not working with rewrite rule

Avatar

Level 4

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?

7 Replies

Avatar

Community Advisor

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

Avatar

Community Advisor

 

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.

Avatar

Community Advisor

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

 

 

Avatar

Level 4

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 ?

Avatar

Level 1

Hi @Anderson_Hamer ,

 

I have a similar kind of issue.Is the above issue resolved?

 

Avatar

Level 1

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