Sachin Shah
Sachin Shah

Reputation: 4533

In my htaccess RewriteRule is not working

I just need to navigate to the subfolder.

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^admin.mydomain.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.admin.mydomain.com [NC]
    RewriteRule ^$ admin/App/ [L]
    RewriteRule (.*) admin/App/$1 [L,NC]
</IfModule>

Can anyone help to show what's wrong in my .htaccess file.

Upvotes: 1

Views: 33

Answers (2)

JP_
JP_

Reputation: 400

It seems you your apache has some issue.

Try this steps

1) cd etc/apache2/

2) sudo vi apache2.conf

Then edit the file and save

<Directory /var/www/>
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All    <------------ Set All 
     Order allow,deny
     allow from all
</Directory>

To save the file :wq

4) sudo systemctl restart apache2

Upvotes: 1

anubhava
anubhava

Reputation: 784968

You may replace your code with this code:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(?:www\.)?admin\.mydomain\.com$ [NC]
RewriteRule ^$ admin/App/ [L]

RewriteCond %{HTTP_HOST} ^(?:www\.)?admin\.mydomain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ admin/App/$0 [L]

Make sure .htacccess is enabled and this is placed in site root .htaccess.

Upvotes: 1

Related Questions