If you’re using PHP Built-in web server just navigate to the folder public
by CMD or Terminal (depends on your operating system), assuming it is in the folder Documents (in windows), do this:
cd C:\Users\[nome do seu usuário]\Documents\projeto-slim\public
php -S localhost:8080 index.php
Ready, should work, but using apache will have to navigate to public, assuming your folder is c:\xampp\htdocs\projeto-slim
or c:\wamp\htdocs\projeto-slim
or c:\apache\htdocs\projeto-slim
, you must access via browser something like:
http://localhost/projeto-slim/public/
Of course, to remove the public from the URL you can use a . htaccess or virtualhost,
VirtualHost
To use the VirtualHost
edit vhost.conf or httpd.conf, it should look something like this:
#Para acessar tudo que não use frameworks
<VirtualHost *:80>
DocumentRoot "c:\apache\htdocs\"
....
</VirtualHost>
# para acessar seu projeto
<VirtualHost *:80>
DocumentRoot "c:\apache\htdocs\projeto-slim\public\"
ServerName meuprojetoslim.exemplo.com
...
</VirtualHost>
# para acessar seu segundo projeto
<VirtualHost *:80>
DocumentRoot "c:\apache\htdocs\projeto-slim2\public\"
ServerName meuprojetoslim2.exemplo.com
...
</VirtualHost>
htaccess
If you cannot edit from Virtualhost you can try from . htaccess, create a . htaccess in the root folder of your site, with something like:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^meuprojetoslim\.exemplo\.com$ [OR] # sem www
RewriteCond %{HTTP_HOST} ^www\.meuprojetoslim\.exemplo\.com$ # com www
RewriteRule ^ projeto-slim2/public/ [L] # o L é pra impedir conflitar com as próximas regras
RewriteCond %{HTTP_HOST} ^meuprojetoslim2\.exemplo\.com$ [OR] # sem www
RewriteCond %{HTTP_HOST} ^www\.meuprojetoslim2\.exemplo\.com$ # com www
RewriteRule ^ projeto-slim2/public/ [L] # o L é pra impedir conflitar com as próximas regras
Of course to the address meuprojetoslim.exemplo.com
work it is necessary to edit the hosts
within the system32
(all this if it is windows), then follow the steps:
- disable the Antivirus
- Open Notepad.exe as administrator
- Press Ctr+O on the Notepad
- When the choose file dialog appears type this
C:\Windows\System32\drivers\etc\hosts
in the field Nome:
This is gonna come up (or good-looking):
# localhost name resolution is handled within dns itself.
127.0.0.1 localhost
::1 localhost
Add this:
# localhost name resolution is handled within dns itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 meuprojetoslim.exemplo.com
127.0.0.1 www.meuprojetoslim.exemplo.com
127.0.0.1 meuprojetoslim2.exemplo.com
127.0.0.1 www.meuprojetoslim2.exemplo.com
Save the document, reactivate the antivirus, restart Apache/Wamp/Xampp, then navigate to the address:
http://meuprojetoslim.exemplo.com
Will access c:\apache\htdocs\projeto-slim\public\
While navigating to:
http://meuprojetoslim2.exemplo.com
Will access c:\apache\htdocs\projeto-slim\public\
When navigating to any other address like: http://localhost
or http://127.0.0.1
Will access c:\apache\htdocs\
You can create a Virtualhost (or a RewriteCode
+RewriteRule
) for each project like this.
Using Apache or php-standalone-server?
– Guilherme Nascimento
Use some . htaccess?
– rray
No, the paperwork says nothing about that.
– Ronaldo Lopes
What a mistake just?
– Jonathan de Toni
@Jonathandetoni he already said
tenho retorno 404
, 404 is a page HTTP status not found.– Guilherme Nascimento