[英]url rewriting with apache2 / php (symfony2)
Consider the following URL: 考虑以下URL:
http://dns/ePhotograph/web/app.php/home
I would like to use URL rewriting so that it is accessible from the following URL: 我想使用URL重写,以便可以从以下URL访问它:
http://dns/home
How can I do that with apache ? 我该如何用apache做到这一点?
EDIT 编辑
This is my vhost file: 这是我的虚拟主机文件:
<VirtualHost 88.191.157.10:80>
ServerName myurl.fr
ServerAlias www.myurl.fr
ServerAdmin email@gmail.com
DocumentRoot /var/www/ePhotograph/web
DirectoryIndex app.php
<Directory "/var/www/ePhotograph/web">
AllowOverride All
Allow from All
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
In your virtualhost configuration, you need to point your document root to web/
and set your index to app.php
. 在您的virtualhost配置中,您需要将文档根目录指向web/
并将索引设置为app.php
。 Then use a rewrite rule to push all urls to app.php
. 然后使用重写规则将所有URL推送到app.php
。
<VirtualHost *:80>
ServerName www.example.com
ServerAlias www.example.com
DocumentRoot "c:\wamp\www\symfony\web"
DirectoryIndex app.php
<Directory "c:\wamp\www\symfony\web">
AllowOverride All
Allow from All
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.