Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/179200-redirect-all-traffic-to-homepage/
Share on other sites

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.

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]

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.