the objective restrict direct access subdomain (addon.example.com) or urls under (addon.example.com/anyurl). should direct 404 page.
what required :
addon.example.com --> example.com/404.html addon.example.com/anyurl --> example.com/404.html example.com/anyurl --> example.com/anyurl i'm using following code in .htaccess file in subdomain (addon domain folder root ) directory.
it works 404 intended, in case request addon.example.com still directs without 404 if request addon.example.com/anyurl
appreciate alternate or tweaks code :)
rewriteengine on rewritecond %{http_host} ^(www\.)?addon\.example\.com [nc] rewriterule (.*) http://example.com/404.php [r=404,l]
this selected solve problem. gives expected...
addon.example.com --> example.com/404.html addon.example.com/anyurl --> example.com/404.html example.com/anyurl --> example.com/anyurl addon.com/anyurl --> addon.com/anyurl .htaccess code used in root directory of addon domain
rewriteengine on options +followsymlinks rewritecond %{http_host} !addon\.com$ [or] rewritecond %{http_host} ^addon\.example\.com$ rewriterule [addon]?(.*) http://example.com/404.html$1 [r=404,l] this comes handy if hosting many domains in cpanel addon domains, , wants avoid addon appearing subdomain of primary domain. seo if want keep each addons appearing no way related in urls.
still appreciate sharing improvements/alternat/efficient .htaccess codes problem.
Comments
Post a Comment