From the Jira text:
Check the Referer header
If the header is:
missing OR
does not originate from our domain
Redirect the user
Applies only when users access the search results page directly with query parameters
Implemented on the dispatcher side
So the rule must:
Use HTTP_REFERER
Target only /search-results.html
Trigger only when query params exist
Redirect to the safe search page
Not affect other pages
example :
when the user hit like below
https://www.sciencedirect.com/topics/computer-science/search-result-page?q=1234455
q=1234455 >>> it should redirect to /search-result-page only and it didn't depend on the domine and brand.
We have one commonredirect.rules are there.
can you please guide me to write the dispatcher rules for this.
Views
Replies
Total Likes
@sesha -
This can be handled cleanly at the Dispatcher (Apache) level using mod_rewrite.
Approach:
Scope strictly to /search-results.html
Trigger only when query parameters exist
Validate HTTP_REFERER
If missing or not from the same host, redirect
Redirect to the safe search page (same URL without params)
Keep it domain/brand agnostic with no impact on other pages
Dispatcher rule (safe for commonredirect.rules):
RewriteCond %{REQUEST_URI} ^/search-results\.html$ [NC]
RewriteCond %{QUERY_STRING} .+
RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER} !^https?://%{HTTP_HOST}/ [NC]
RewriteRule ^/search-results\.html$ /search-results.html? [R=302,L]
Result:
Direct access like /search-results.html?q=123 redirects to /search-results.html, while normal in-site navigation continues to work.
Views
Replies
Total Likes
@lavishvasuja , Frist of all thankyou for replying me.
I have try to update the same rules in the dispatcher and after updating this rules, the complete dispatcher goes to 503 bad request. Dispatcher is completely blocking.
we have three dispatcher after updating this the dispatcher goes like down.
can you please help on this.
Views
Replies
Total Likes
A 503 usually means Apache failed to evaluate the rewrite safely (not a redirect issue). Since this is in commonredirect.rules, a strict condition can break all requests.
Try this safer Dispatcher rule :
RewriteCond %{REQUEST_URI} ^/search-results\.html$ [NC]
RewriteCond %{QUERY_STRING} .+
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER} !^https?://[^/]+/ [NC]
RewriteRule ^ /search-results.html? [R=302,L]
This drops query params only for direct hits, avoids loops, and won’t impact other pages. If it still fails, Apache error.log will point to the exact rewrite issue.
Views
Replies
Total Likes
still I'm getting like that only if i update the rules. so only thing is if I pass the search-result.html?q=1237855saa >>>> it should redirect to search-result.html page only. can you please help me on this.
thankyou..!
Views
Replies
Total Likes
Hi @sesha
Go to:
dispatcher/src/conf.d/rewrites/
Create new file:
commonredirect.rules
RewriteCond %{REQUEST_URI} ^/search-results\.html$ RewriteCond %{QUERY_STRING} .+ RewriteCond %{HTTP_REFERER} ^$ [OR] RewriteCond %{HTTP_REFERER} !^https?://(www\.)?yourdomain\.com [NC] RewriteRule ^(.*)$ /search-result-page? [R=302,L]
Edit:
dispatcher/src/conf.d/rewrites/rewrite.rules
After this line:
Include conf.d/rewrites/default_rewrite.rulesapache
Add this line:
Include conf.d/rewrites/commonredirect.rulesapache
In
commonredirect.rules
, replace
yourdomain\.com
with your actual domain
Direct access:
https://yoursite.com/search-results.html?q=test
From your site: Should work normally
No query params: Should work normally
Views
Replies
Total Likes
Views
Likes
Replies