Change document root using .htaccess on wamp

I scratch him for a long time over my head. Cannot get it to work. (I am a noob with apache, which may be one reason). Well, here's the problem in a nutshell. I use wamp and I have a directory Retailer. It has another directory called public, which contains an index and other files. I want to make this root directory of the publicroot directory . I want to achieve this with.htaccess

My Rewrite module for apache is included.

Here is what I tried:

RewriteEngine on
RewriteBase /public/
RewriteRule ^index.php$ test.php

And also I tried

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^localhost/Retailer$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^localhost/Retailer$ 
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

And I tried

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^http://localhost/Retailer/$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^http://localhost/Retailer/$ 
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

But the result in all these cases is the same. I.e: enter image description here

Any help would be appreciated by Ahmar

+4
source share
2 answers

Retailer/.htaccess:

RewriteEngine on
RewriteBase /Retailer/

RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
+4

.htaccess, apache httpd.conf:

<VirtualHost 127.0.0.1:80>
  DocumentRoot "/path/to/project/Retailer/public"  
  ServerName "retailer.local"
  ServerAlias "www.retailer.local" 
</VirtualHost>

hosts :

127.0.0.1 retailer.local

-!

+3

Source: https://habr.com/ru/post/1524573/


All Articles