Model view controller ARRW-另一个重写规则
我很抱歉,因为有很多这样的问题,但我无法通过 要求 在Symfony2项目中,我希望在URL中没有php控制器的情况下访问页面,例如:Model view controller ARRW-另一个重写规则,model-view-controller,.htaccess,mod-rewrite,symfony,Model View Controller,.htaccess,Mod Rewrite,Symfony,我很抱歉,因为有很多这样的问题,但我无法通过 要求 在Symfony2项目中,我希望在URL中没有php控制器的情况下访问页面,例如: # This is the present use : GET /af/index.php/myURI HTTP/1.1 OK ~ 但是我得到一个404错误,要么是默认的.htaccess,要么是自己的版本 .htaccess 默认访问权限: <IfModule mod_rewrite.c> RewriteEngine On Rew
# This is the present use :
GET /af/index.php/myURI HTTP/1.1
OK
~
但是我得到一个404错误,要么是默认的.htaccess,要么是自己的版本
.htaccess
默认访问权限:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
我已将web/目录动态链接到/var/www/af
编辑-我发现:
在每个目录的.htaccess文件中使用重写引擎时
前缀(对于特定目录始终相同)为
为重写规则模式匹配而自动删除,并且
自动添加在任何亲戚之后(不以斜线或斜线开头)
协议名称)替换遇到规则集的结尾。见
RewriteBase指令,了解有关将使用哪个前缀的更多信息
可以添加回相对子条件
不要更改.htaccess文件规则 如果您有权访问webserver配置文件(即本地开发人员或虚拟机),则需要将VirtualHost规则添加到
httpd.conf
中。
大概是这样的:
<VirtualHost *:80>
DocumentRoot "/var/www/af/web"
ServerName af
<directory "/var/www/af/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
DocumentRoot“/var/www/af/web”
服务器名af
选项索引跟随符号链接
允许超越所有
命令拒绝,允许
全盘否定
允许从127.0.0.1开始
如果您无法访问web服务器配置文件(即共享主机),则需要将
web
文件夹链接为公共访问文件夹(有时命名为public\u html
)问题已解决,原因是:我的文档根目录不允许对htaccess进行过度访问。我无法做到这一点。这是一个git控制的项目,我不想在每个部署上配置virtualhost。事实上,大多数CMSE(Joomla、Drupal、Wordpress等)都有这种重定向,我们不需要添加新的virtualhost。好的,你的答案在里面:我必须在通用公共文档根中添加“AllowOverride all”。谢谢:-)哈哈,很高兴我能帮上忙。。我想-D
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase /af
# Options +FollowSymLinks
# Isn't the request for a regular file ?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
/var/www/af
├── app
├── bin
├── src
├── vendor
└── web
├── app_dev.php
├── apple-touch-icon.png
├── bundles
├── config.php
├── favicon.ico
├── .htaccess
├── index.php
└── robots.txt
<VirtualHost *:80>
DocumentRoot "/var/www/af/web"
ServerName af
<directory "/var/www/af/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>