J
J
John Bjornsen2018-09-02 17:59:06
Apache HTTP Server
John Bjornsen, 2018-09-02 17:59:06

How to solve the problem with organizing a common entry point to the site?

I'm trying to make a single entry point to the site. There is such a structure:
/
-public
--index.php
.htaccess

Since this project is being built on a virtual host, I wrote the following in httpd-vhosts.conf:

<VirtualHost *:80>
  DocumentRoot "d:/wamp64/www/phptest.loc/public"
  ServerName phptest.loc
  ErrorLog "logs/phptest.localhost-error.log"
  CustomLog "logs/phptest.localhost-access.log" common
  <Directory  "/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

index.php file :
<?php
echo 'Requested URL = ' . $_SERVER['QUERY_STRING'];

Content of .htaccess file :
AddDefaultCharset utf-8
Options -Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

The problem is that when requested, for example, phptest.loc/smth?param=1 should output smth?param=1 , but it outputs public/smth¶m=1 . Firstly, where does the icon of non-printable characters appear and part of the word param disappears, and secondly, why is the name of the public directory that I specified as the root directory of the site displayed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-09-02
@Bjornsen

Your server should look in /Public, so htaccess should be in it.
Example (Public folder structure):
https://github.com/laravel/laravel/tree/master/public

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question