The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “CPA

Redirect non-matching URL's via htaccess

M

michael pehl

Guest
Hi again.

This time I just want to show you how to redirect non-matching URL's via some simple htaccess.

If someone is e.g. typing a wrong URL (http://yourdomain.com/idnex.html) he will get redirected to any site you specify.

Here it goes:

Code:
# redir to e.g. any affiliate site if file/folder not found ;-)

RewriteEngine On
RewriteCond %{HTTP_HOST} =yourdomain.com [OR,NC]
RewriteCond %{HTTP_HOST} =www.yourdomain.com [NC]
# 404 test -- file/folder exists?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*) http://www.domaintoredirectto.com [R=301]

Paste these lines to .htaccess e.g. in your web root, change yourdomain.com and www.domaintoredirectto.com, done.

Questions? Ask me.

DEMO: http://w3cvalidco.de/idnex.html

Want to support me? Click here
 
banners
Back