• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

301 redirect

I want to redirect 403 to another domain.

IE: I have a program on another domain that has links to our site. The links are local for example:

about.php is on siteB but is not on siteA. I don't want to put full paths of the links in because when I update my navigation file I copy it from the other site to this one. I would rather htaccess do this:

if about.php does not exist 301 redirect to http://www.siteb.com/about.php

and do on. However, I do not want it to redirect on existing files for example index.php should not redirect.
Robert Saylor
Robert Saylor
  • 2
  • 2
1 Solution
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(about).php$ http://www.siteb/$1.php [R=301,NC,L]

Open in new window

Robert SaylorSenior DeveloperAuthor Commented:
Anyway to not have to write out the filenames?

RewriteRule ^/?(*).php$ http://www.siteb/$1.php [R=301,NC,L]

Can I use a wildcard then exclude files that exists?
RewriteRule ^/?(.+)\.php$ http://www.siteb/$1.php [R=301,NC,L]
Robert SaylorSenior DeveloperAuthor Commented:
THANK YOU saved me a bunch of time!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now