Hey all,
I'm attempting to write an apache mod_rewrite statement on my dispatcher that will redirect a URL only if the file does not exist/hasn't been published yet.
For example, if I have a page that does not exist named
www.testsite.com/dir1/non-existing-page-123
and one that does exist named
www.testsite.com/dir1/existing-page-123
The dispatcher should check if the file exists and redirect the non-existing-page-123, but serve the existing-page-123. For clarity - this is from an old content migration, now is a mix of old + new content URLs.
I wrote the mod_rewrite statement below that checks for the file to not exist, but I realized that the file will only exist on the dispatcher if it is cached and the dispatcher should be checking the publisher for the existence of the page. This below statement redirects everything with a -123 at the end of it to the /dir 1 page, existing or not.
RewriteCond ^dir1/(.+)-123 -!-f
RewriteRule ^dir1/(.+)-123 /dir1 [L,R=301]
I have other rewrite conditions and rules that are working okay, but this is my first one dealing with a conditional to check for a file.
Is there a way in apache mod_rewrite on the dispatcher to check if a file has been published from AEM?
Thanks
Brendan