繁体   English   中英

Silex路由.htaccess webroot

[英]Silex routing .htaccess webroot

我正在使用Silex“微框架”来进行应用程序的路由。 我目前仍然坚持如何使用.htaccess重写网址。

标准Silex网址: localhost/myapp/web/index.php/hello/name

我希望它看起来像: localhost/myapp/hello/name

使用以下.htaccess代码,我可以省略/index.php/部分。 但我仍然需要使用/web/ part。

RewriteEngine On
RewriteCond %{THE_REQUEST} /myapp/web/index.php/
RewriteRule ^/myapp/web/index.php/(.*) /myapp/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !/myapp/web/index.php/
RewriteRule ^(.*)$ /myapp/web/index.php/$1 [L]

有什么建议? 谢谢!

我现在面临同样的问题,解决方案是将.htaccess内容更改为:

FallbackResource /index.php

所以在你的情况下它会

FallbackResource /web/index.php

这对我有用,我希望有人会发现它很有用。

来自: http//silex.sensiolabs.org/doc/web_servers.html

<IfModule mod_rewrite.c>
    Options -MultiViews    
    RewriteEngine On
    RewriteBase /web
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

正确的方法是将DocumentRoot设置为/path/to/your/app/web

像这样的东西应该做的伎俩:

RewriteEngine On
RewriteBase /

RewriteRule ^myapp/web/index.php/  /myapp/                 [R=301,L]
RewriteRule ^myapp/                /myapp/web/index.php/   [L]

我遇到了类似的问题,解决了以下问题

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

暂无
暂无

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

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