[英]url rewriting with apache2 / php (symfony2)
考慮以下URL:
http://dns/ePhotograph/web/app.php/home
我想使用URL重寫,以便可以從以下URL訪問它:
http://dns/home
我該如何用apache做到這一點?
編輯
這是我的虛擬主機文件:
<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>
在您的virtualhost配置中,您需要將文檔根目錄指向web/
並將索引設置為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.