yunusdjanov
yunusdjanov

Reputation: 26

htacces is not redirecting

enter image description here I have root file and in root file public => index.php.I created .htaccess in root and wrote this code

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

to redirect from root to public/index.php but it is not working. localhost is wamp(apache)

Upvotes: 0

Views: 125

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133428

If I get your question correctly, could you please try following. This simply checks if REQUEST_URI is null then move further to rewriterule to redirect it in backend to index.php file

RewriteEngine ON
RewriteBase /
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /public/index.php [L]

IMHO When you are using public/$1 in right side of your rewriterule $1 is empty since it's REQUEST_URI value is NULL because you are hitting base url, so its better to write /public/index.php there.

Upvotes: 1

Related Questions