A
A
Alexander Karpov2017-04-07 21:20:02
Apache HTTP Server
Alexander Karpov, 2017-04-07 21:20:02

Why doesn't mod_rewrite work on the site root?

I have such a .htaccess setting, at addresses like /asda/asda/ and others, the redirect works as expected, but if you just open site.ru/ then app.php does not work, instead the apache welcome page is spit out. Tell me if it's not difficult.
I spent a couple of hours at first with what I thought mod_rewrite did not work at all, but it turned out to work, just not on the main page... uff...
Thank you!

<IfModule mod_rewrite.c>
    RewriteEngine On
    Options +FollowSymlinks
    #RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ app.php?u=$1 [L,QSA]
</IfModule>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey L, 2017-04-07
@Inkognitoss

DirectoryIndex app.php

<IfModule mod_rewrite.c>
…

Will help. Or look in the server settings where the indexes are assigned.
DirectoryIndex
This directive allows you to specify the name of a document returned by a request that does not contain a document name in the URL string. For example, the URL www / does not contain a document name, so the document specified in the DirectoryIndex directive will be returned. Because the default name is index.html, the server will serve the client an index.html document from the DocumentRoot directory on the server.

A
Axian Ltd., 2017-04-07
@AxianLTD

For the root, index.html, php, etc. are searched. Specify app.php as the index file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question