已解决)如何从苗条框架网址中删除'/index.php'

问题描述 投票:0回答:2

我的开发环境是

Ubuntu 14.04.6 LTS

Apache 2.4.7

mysql是5.6.33

我的目录是

/var/www/html/your-app
                   |--public
                   |-- .htaccess
                   |      `-- index.php
                   `--app
                       |-- src
                       |    |-- controllers
                       |    |       `-- WebController.php
                       |    `-- models
                       |            `-- WebModel.php
                       |-- templates
                       |    |-- main.html
                       |    `-- signup.html
                       |-- dependencies.php
                       |-- middleware.php
                       |-- routes.php
                       `-- settings.php

苗条框架的根路径正常工作。

my_slim_url/index.php

my_slim_url

// load the same page

但是,要像这样移动到我的主屏幕上的另一个链接

my_slim_url/signup

此消息,

'The requested URL / register_email was not found on this server.' 

显示。

我已经尝试了所有关于stackoverflow的答案,但是它们没有用。

以下是我服务器的一些代码可能会有所帮助。

[如果您告诉我,到目前为止我没有发现任何问题或解决方法,

感谢您的帮助。

我希望每个人都可以正确编码...:D

apache2.conf

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<Directory /var/www/html/public>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<ifModule dir_module>
    DirectoryIndex index.php
</ifModule>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

/ sites-available / 000-default.conf

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all granted
 </Directory>

<Directory /var/www/html/your-app/public>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

/ var / www / html / your-app / pulbic / .htaccess

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

apache ubuntu mod-rewrite slim
2个回答
0
投票
根据Slim Framework user guide,您的.htaccess(在/var/www/html/your-app/public/.htaccess)应包含:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L]


0
投票
我解决了这个问题!!!!

首先,运行此功能:

$ sudo a2enmod rewrite
第二,检查您的apache2.conf目录UR​​L:

<Directory /var/www/html/public> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
过去,我这样改变,

<Directory /var/www/html/your-app/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

第三,重新启动apache服务

$ sudo service apache2 restart
然后,它起作用了!!!

谢谢大家回答我的问题!!! :D

© www.soinside.com 2019 - 2024. All rights reserved.