简体   繁体   English

htaccess可能仅在cakephp 3.6中运行默认路由

[英]Only default Routing working in cakephp 3.6, may be issue with htaccess

I am download the cakephp 3.6 and when i am tring to use default route it works fine. 我正在下载cakephp 3.6,当我尝试使用默认路由时,它可以正常工作。 but when i add something after / . 但是当我在/之后添加一些内容时。 it git me 404 error here is my router code 它使我404错误,这是我的路由器代码

 $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);


$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);

when I request for http://localhost/cake/my_app_name/ it work fine but when I hit for http://localhost/cake/my_app_name/pages/10 it gives me 404 error 当我请求http:// localhost / cake / my_app_name /时,它工作正常,但是当我点击http:// localhost / cake / my_app_name / pages / 10时,它给我404错误

my webroot htaccess file code is here 我的webroot htaccess文件代码在这里

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

app htaccess code is here 应用程式htaccess程式码在这里

 # Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
#    RequestHeader unset Proxy
#</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^(\.well-known/.*)$ $1 [L]
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

You need to add AllowOverride All directive to your app's folder in Apache config. 您需要将AllowOverride All指令添加到Apache配置中的应用程序文件夹中。

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

您需要创建一个名为10.ctp的文件,并将其放入src / Template / Pages。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM