Sam*_*Sam 6 php apache url-rewriting symfony
请考虑以下URL:http://www.myurl.fr/accueil.
它不会起作用.但是http://www.myrurl.fr/app.php/accueil确实有效.
我摆脱了.htaccess文件,因为我想使用vhost文件并依赖Apache路由.我的vhost文件如下:
<VirtualHost my.ip.address>
ServerName myurl.fr
ServerAlias www.myurl.fr
DocumentRoot /var/www/mysite/web
DirectoryIndex app.php
<Directory "/var/www/mysite/web">
AllowOverride All
Allow from All
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
RewriteRule .? - [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ app.php [QSA,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我已经清除了Apache缓存并重启了很多次.urlrewrite mod已启用.我只是不知道还有什么要检查.知道我错过了什么吗?
编辑 可能是因为我正在处理它,所以这两个URL都不能在给定的时间运行.我的问题仍然有效.
将您的规则与symfony-standard .htaccess进行比较,我发现您在"传递所有规则"之前错过了文件检查.尝试
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
# Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9465 次 |
| 最近记录: |