skip to Main Content

As the title says, I have the root directory that contains pages and I have another directory that it’s called mobile.

I would like the pages that are inside the root directory to be all redirected to index.php in root, as for the mobile directory I want all the pages inside it to be redirected to the other index.php that is inside /mobile

I have tried multiple times but it seems that sometimes I can only get one folder working at a time.

Any help would be much appreciated !

Thank you

2

Answers


  1. Paste this code both in site root .htaccess and mobile/.htaccess:

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    
    Login or Signup to reply.
  2. Use Nginx. 😉

    Example.

    location ~ ^/lol/index.php$
    {
        alias /var/www/abc/lol/index.php;
    }
    
    location ~ ^/lol/
    {
        return 302 https://example.org/lol/index.php;
    }
    
    location ~ ^/index.php$
    {
        alias /var/www/abc/index.php;
    }
    
    location ~ ^/?
    {
        return 302 https://example.org/index.php;
    }
    

    Skills required: RegEx (~).

    The HTTP status code 302 causes your browser to switch to this page. I don’t like 301 so much when developing, because your browser remembers the redirects or caches them.

    With the location blocks it depends of course also on the order.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search