Thursday, May 16, 2024
 Popular · Latest · Hot · Upcoming
20
rated 0 times [  20] [ 0]  / answers: 1 / hits: 27639  / 3 Years ago, mon, august 23, 2021, 3:19:25

I'm making an advertisement blocking DNS server that redirects all the advertisement domains to an instance of Apache. So something like



www.addomain.com


gets redirected to



dnsserver.localnetwork


However, occasionally I come across links more like



www.addomain.com/some_ad


which gets redirected to



dnsserver.localnetwork/some_ad


which doesn't even exist and hence raises a 404 error.



I was hoping that there would be some way to make Apache serve index.html, regardless of the actual request. Otherwise, if you have an alternate solution that does not involve Apache, I'm up for that too.


More From » apache2

 Answers
3

In Ubuntu, make sure mod_alias is enabled:



sudo a2enmod alias


Then in your VirtualHost directive you can use AliasMatch.



Example:



<VirtualHost *:80>
DocumentRoot /path/to/your/host
ServerName yourdomain.com
DirectoryIndex index.html

AliasMatch ^/(.*)$ /path/to/your/host/index.html

<Directory "/path/to/your/host">
Require all granted
</Directory>
</VirtualHost>


Now everything gets redirected to /index.html.


[#24569] Wednesday, August 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elopingapo

Total Points: 206
Total Questions: 110
Total Answers: 114

Location: Guam
Member since Tue, Nov 29, 2022
1 Year ago
elopingapo questions
Fri, Sep 10, 21, 17:52, 3 Years ago
Tue, May 24, 22, 00:42, 2 Years ago
Sat, Apr 23, 22, 03:16, 2 Years ago
Fri, Jan 13, 23, 06:41, 1 Year ago
;