1

i have a trivial question about htaccess rewrite condition. The think i want to do in my htaccess is:

When someone accesses my project from a url different from "example.com" to be redirected to a specific controller, for example app_user.php

I need the syntacs for this condition redirect.

Thanks for your time

2
  • This is unclear: accesses my project from a url different from "example.com" Accesses how? What is "my project"? This could be a referrer issue, or an issue with several server aliases pointing to the same server... Commented Dec 20, 2013 at 15:28
  • I got my answer, but ill make the question more clear just for future references. I have more than 1 domains pointing to my web project. I want all of the domains which arent "example.com" when accessing the project to be redirected to a specific front controller. Commented Dec 20, 2013 at 15:31

1 Answer 1

3

Try this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/app_user.php
RewriteRule ^ /app_user.php [L]
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry if i hadn`t explained it properly. I need when some accesses my project from a different url from : "example.com". The example that you gave fixes the problem if the path after the url is diferent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.