I am trying to create a .htaccess rule to redirect users from one domain to the other, but this should happen only if the original URL does not exist. For example:
www.domain.com/100towww.otherdomain.com/PersonalPages/100www.domain.com/150towww.otherdomain.com/PersonalPages/150
Now, I don’t have a page/file named 100 or 150, so that’s why it should redirect, but if user enters “www.domain.com” I do have “index.php” and should stay in “www.domain.com” and not try to go to “www.otherdomain.com/PersonalPages/index.php” (or any other if page exist in my http://www.domain.com)
I know I can create a simple 301 redirect, but the numbers in the URL are the IDs of users and that number will grow on a daily basis so I can’t be adding lines of redirects to my .htaccess for each new user.
Is there a 404 code I could use?
I think this will work for you:
^and$mark the beginning/end of the url,[0-9]+stands for one or more numbers between 0 and 9.