Htaccess [SOLVED]: htaccess FallbackResource redirecting root domain

Htaccess [SOLVED]: htaccess FallbackResource redirecting root domain

Home Forums htaccess Htaccess [SOLVED]: htaccess FallbackResource redirecting root domain

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36981

    Anonymous

    QuestionQuestion

    I am using FallbackResource to redirect any missing links to /user.php but it will redirect root domain (“incupe.com”) too. It shouldn’t redirect that! It will only stop redirecting if “incupe.com/index.php” is explicitly entered. Please help! This is my .htaccess file:

    # Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
    RewriteBase /
    
    # Always use https for secure connections
    # Replace 'www.example.com' with your domain name
    # (as it appears on your SSL certificate)
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.incupe.com/$1 [R=301,L]
    
    Options All -Indexes
    FallbackResource /user.php
    

    Thanks in advance!

    #36982

    Anonymous

    Accepted AnswerAnswer

    If you only want to redirect missing links to user.php, put the following into .htaccess instead of your code.

    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ user.php [L]
    
    Options All -Indexes
    

    If you have any virtual URLs, this won’t work.

    Source: https://stackoverflow.com/questions/48047663/htaccess-fallbackresource-redirecting-root-domain
    Author: olegsv
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.