I've got a hosting that is shared by which I wish to host several websites. As a result, and also to keep things obvious, I've rerouted my primary domain (i.e. world wide web.mydomain.com) to some folder (i.e. /mydomain.com/). However, I wish to prevent immediate access for this folder (world wide web.mydomain.com/mydomain.com/) in the URL having a 404 error (not found).
This is actually the .htaccess within the root directory:
RewriteEngine On RewriteBase / RewriteCond % ^(world wide web.)?mydomain.com$ [NC] RewriteCond % !^/mydomain.com/.1/$ [NC] RewriteRule ^(.*)$ /mydomain.com/.1/$1 RewriteCond % ^(world wide web.)?mydomain.com$ [NC] RewriteRule ^(/)?$ mydomain.com/.1/index.php [L] RewriteCond %% ^[A-Z] /mydomain.com/ [NC] RewriteRule . - [R=404,L]
And this is actually the .htaccess in /mydomain/ with a lot of rules for nice tidy Web addresses.
RewriteEngine On RewriteRule ^about/(.+) index.php?a=about&b=$1 RewriteRule ^services/(.+) index.php?a=services&b=$1
At this time this is actually the result:
Being able to access world wide web.mydomain.com shows this content in /mydomain/ as wished. However, world wide web.mydomain.com/mydomain/ can also be displayed, disregarding the 404 rule, and creating another folder -regardless of the title- with no htaccess DOES toss the 404.
I have been coping with this issue for five days now and attempted everything. At this time I'm not sure when the error originates from the main .htaccess or even the folder's.
Thanks ahead of time.
PS: Simply to be obvious, I've no treatments for the httpd.conf file.
- I didn't remember stating that there's one more folder inside /mydomain.com/ known as /.1/ for version control.
- If your include "RewriteOptions Inherit" after "RewriteEngine On" within the /mydomain.com/.1/ htaccess, I recieve a 500 internal server error.
- Removing the /mydomain.com/.1/ htaccess file altogether will make the preferred 404 error for world wide web.mydomain.com/mydomain.com/.1/ and convey a 505 in world wide web.mydomain.com
R flag in rewrite rule ought to be something between 301 to 399 , so it cannot be 404!!!
your rule ought to be like below:
RewriteCond % ^/mydomain.com/? [NC] RewriteRule (.*) throw_404.php [L]
throw_404.php and also to send 404 status code! and add
L flag for your first rule for staying away from conflicting between that rule and mine!