skip to Main Content

I want to load index.php by default BUT if there is call or call.php in url it should load call.php file instead:

Default URL (below URLs should load ROOT/index.php):

http://example.com/rgt-cfjv-vlm
http://example.com/index.php/rgt-cfjv-vlm

Other URL (below URLs should load ROOT/call.php):

http://example.com/call/rgt-cfjv-vlm
http://example.com/call.php/rgt-cfjv-vlm

NOTE “rgt-cfjv-vlm” is a random string and it will always come in URL

Any help will be appreciated! Thanks.

2

Answers


  1. Chosen as BEST ANSWER

    Workaround: I have changed my directory structure as below:

    For Default URL (http://example.com/rgt-cfjv-vlm):

    ROOT/index.php

    ROOT/.htaccess

    RewriteEngine On
    Options +FollowSymlinks
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [NC,QSA]
    

    For Other URL (http://example.com/call/rgt-cfjv-vlm):

    ROOT/call/index.php

    ROOT/call/.htaccess

    RewriteEngine On
    Options +FollowSymlinks
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [NC,QSA]
    

    Now its loading ROOT/index.php on http://example.com/rgt-cfjv-vlm and ROOT/call/index.php on http://example.com/call/rgt-cfjv-vlm.

    I believe there will be some better solution but using it on temporary bases.


  2. here you go:

    RewriteEngine on
    
    RewriteCond %{REQUEST_URI} call
    RewriteRule .* call.php 
    
    RewriteCond %{REQUEST_URI} !call
    RewriteRule .* index.php 
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search