soycharliente Posted October 27, 2009 Share Posted October 27, 2009 Is it possible to redirect all URLs under my domain to a specific URL so that whenever someone tries to go to domain.com/anythingatall it would redirect to a specific place? I found online that using ErrorDocument 404 http://www.example.com/ would do it, but I'd have to place that in each directory. Is what I'm asking for not possible and I would have to in fact place a separate .htaccess file in every directory? I also found... RewriteEngine On RewriteRule (.*) http://new.example.com/$1 [L] But would that cause an infinite loop? I don't really know how to do this stuff and Googling doesn't seem to be helping for my specific problem. How would I exclude my index.php file in my root and well as everything in my /blog/ directory from this rule? That seems to be what I'm looking for. Quote Link to comment https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/ Share on other sites More sharing options...
cags Posted October 27, 2009 Share Posted October 27, 2009 What makes you think you'd need to place the first one in each directory? Providing you put the .htaccess file in your root directory that will apply to everything. It basically sets a 404 error (which is file not found) and takes the user to a script that would normally explain that and provide key links or search functionality. Quote Link to comment https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/#findComment-945543 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2009 Share Posted October 27, 2009 i took this from the zend framework site it rewrites everything to go to your index page, goes in htaccess in your root RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] Quote Link to comment https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/#findComment-945544 Share on other sites More sharing options...
soycharliente Posted October 27, 2009 Author Share Posted October 27, 2009 What makes you think you'd need to place the first one in each directory? Just the explanation that I read on a site about using mod_rewrite. So it is possible to do this? Can you point me to a site that could explain how to go about redirecting all traffic to root index.php except a specific folder? Maybe something about a conditional statement? I don't like just asking for answers. Quote Link to comment https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/#findComment-945545 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2009 Share Posted October 27, 2009 http://framework.zend.com/manual/en/project-structure.rewrite.html http://www.widexl.com/tutorials/mod_rewrite.html Quote Link to comment https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/#findComment-945546 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2009 Share Posted October 27, 2009 rewriteRule ^specific_folder(.+)/(.+).html specific_folder [L] total guess looks like the first one is the url found and the second one is what to convert it to. somthing like that Quote Link to comment https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/#findComment-945547 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.