mod_rewrite和.htaccess的问题将无法解决

时间:2018-09-29 13:19:32

标签: php laravel .htaccess apache2

我更改了此主题,因为我无法添加新问题。 我正在尝试删除index.php,但我无法删除它。

我要重写指向www / admin的链接,而不是www / index.php / admin mod_rewrite已启用,我将/etc/apache2/sites-enabled/000-default.conf更改为:

<VirtualHost *:80>
        ServerName localhost
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

www中的.htaccess文件更改为:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    RewriteBase /

    #First rewrite any request to the wrong domain to use the correct one (here www.)
    #RewriteCond %{HTTP_HOST} !^www\. [NC]
    #RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    RewriteRule ^(.env) - [F,L,NC]

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

Bu,当我转到www时页面工作正常,如果我添加www / admin,则会出现错误 当我添加index.php时:www / index.php / admin我可以访问管理员 但我无能为力。我需要删除index.php。

我希望有人能帮助我。

0 个答案:

没有答案
相关问题