Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kamish's avatar

remove index.php from the url

Hi, I'm trying to remove the INDEX.PHP From the URL, but it does not work. PUBLIC folder I have httacses file with the following code:               Options -MultiViews      </ IfModule>

     RewriteEngine On

     # Redirect Trailing Slashes ...      RewriteRule ^ (. *) / $ / $ 1 [L, R = 301]

     # Handle Front Controller ...      RewriteCond% {REQUEST_FILENAME}! -d      RewriteCond% {REQUEST_FILENAME}! -f      RewriteRule ^ index.php [L] </ IfModule>

It is important to note that I was working on a local server Apache

0 likes
4 replies
bashy's avatar

Is your DocumentRoot pointing to laravel core or /public? If you can browse to /composer.json on your domain, you will have to do the above or change your DocumentRoot so that the public folder is the top level

kamish's avatar

I tried and failed . I may have problems with the definition of the Apache ?

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/public
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

bashy's avatar
bashy
Best Answer
Level 65

In <Directory /var/www/public> block, change

AllowOverride None

to

AllowOverride All
2 likes

Please or to participate in this conversation.