问题
I'm using symfony in my local computer for programming. its address is http://localhost/RTL/web/app_dev.php/secure_area
.
How can I change this address to http://localhost/secure_area
?
I mean removing RTL/web/app_dev.php
.
I'm using xampp, apache and symfony 2.6.
other addresses could be something like these:
http://localhost/RTL/web/app_dev.php/login => http://localhost/login
http://localhost/RTL/web/app_dev.php/logout => http://localhost/logout
http://localhost/RTL/web/app_dev.php/admin => http://localhost/admin
回答1:
Accordingly to the comments.
The RTL/web is removed adding the directive DocumentRoot "C:/xampp/htdocs/localhost/RTL/web"
on your virtual host file in apache.
Then you can hide app.php using these apache mod_rewrite rules:
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]
then restart apache server to apply the modifications.
来源:https://stackoverflow.com/questions/27460935/how-to-set-the-web-root-and-hide-app-php-and-app-dev-php-in-localhost-using-xamp