0

In my var/www/html/ folder there are 2 Angular applications.

One is search and the other one login. There is no index.html file in /var/www/html/ only 2 folders which contains each a index.html file.

What I want to do is when a user goes to http://mydomain.de/ The user will be redirected to the folder /var/www/html/search/ Also in all other cases: e.g. http://mydomaim.de/notexisting

In the Search page there is a link to http://login/, folder /var/www/html/login/

So when the user goes to http://mydomain.de/login, it should redirect to this folder.

My tries so far: RewriteEngine On

RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
#RewriteRule login$ /login/index.html$1 [N]
#RewriteRule ^search*/$ /search/index.html$1 [L]

RewriteCond %{REQUEST_URI} !^/search/
RewriteRule (.*) /search/$1

RewriteCond %{REQUEST_URI} !^/login/
RewriteRule (.login*) /login/$1

Thank you and Kind Regards,

PS: When I only use this search page is working but not the login page.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/search/
RewriteRule (.*) /search/$1
  • “What I want to do is when a user goes to … The user will be directed to … Also in all other cases.” — This is logical the same as “always direct user to …”. I am sure this is not what you meant, and it is central to you question, can you edit to clarify. – ctrl-alt-delor Jun 17 at 22:32
0

It's simple if you only want to exclude /login/ from your RewriteRule:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/search/
RewriteCond %{REQUEST_URI} !^/login/
RewriteRule (.*) /search/$1 [R,L]

I added the flags [R,L] for a 302 redirect and to stop processing of any further rules in your .htaccess file. You can remove the R if you don't want redirection to take place.

Flags:

  • thank you really :) this solved my problem. I am totaly new with this. – Raijin92 Jun 18 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.