I have scratching my head over it for a long time now. Can't manage to get it to work. (I am a noob with apache that can be one reason also). Ok here is the problem in nutshell. I am using wamp and I have a directory Retailer
. There is another directory inside it which is called public that contains the index and otherfiles. I want to make this public
directory document root. I want to achieve this with .htaccess
My Rewrite module for apache is turned on.
Here is what I have tried:
RewriteEngine on
RewriteBase /public/
RewriteRule ^index.php$ test.php
And also I have 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 have 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 result in all these cases is the same. That is:
Any help will be appreciated Ahmar
Use this rule in your Retailer/.htaccess
file:
RewriteEngine on
RewriteBase /Retailer/
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
You should config this not in .htaccess
file but in apache config file httpd.conf
:
<VirtualHost 127.0.0.1:80>
DocumentRoot "/path/to/project/Retailer/public"
ServerName "retailer.local"
ServerAlias "www.retailer.local"
</VirtualHost>
Also you need to update your hosts
file with the next line:
127.0.0.1 retailer.local
And restart your web server!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With