VDS Sphera Knowledge Base

Main / Browse Categories / Apache / How can I redirect users trying to access any page on my site to the homepage?

Print article Print Article    Email article Email Article

How can I redirect users trying to access any page on my site to the homepage?
If you want to use the mod_rewrite engine, put the following in an .htaccess file, and edit accordingly:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.YOUR_DOMAIN [NC]
RewriteCond %{HTTP_REFERER} !^http://YOUR_DOMAIN [NC]
RewriteCond %{HTTP_REFERER} !^http://YOUR_IP_ADDRESS [NC]
RewriteCond %{HTTP_REFERER} !^http://www.YOUR_DOMAIN:80 [NC]
RewriteCond %{HTTP_REFERER} !^http://YOUR_DOMAIN:80 [NC]
RewriteCond %{HTTP_REFERER} !^http://YOUR_IP:80 [NC]
RewriteRule /* http://YOUR_REDIRECT [R,L]
Additional resources:
mod_rewrite - A Beginner's Guide to URL Rewriting
mod_rewrite Cheat Sheet - Cheat Sheets - ILoveJackDaniels.com
Redirect Webpages to Another Domain
URL Rewriting | redirecting URLs with Apache’s mod_rewrite
Apache 1.3 URL Rewriting Guide

User Comments
How can I redirect users trying to access any page on my site to the homepage?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 Where is the Apache httpd.conf file located?
 How do I restart Apache?
 How can I create a Script Alias in Apache to Neomail?
 How can I prevent Directory Listing?
 How do I prevent hot linking of my pictures, movies, or other files?

Why Choose Our Hosting?

  • Unmatched Customer Support!
  • Virtual Private Server technology provides a rich, dedicated-like environment for every account.
  • We are known for our superb quality, performance and flexible hosting environment. We manage the server, software, and network you do the rest.
Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Parallels® Plesk Panel 10
  • Unique IP Address
  • Daily VPS Backups (Off Server)
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »