Home > Back-end >  Url redirect from one to another url using htaccess
Url redirect from one to another url using htaccess

Time:04-25

Currently this is in my .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/index.php [L]
</IfModule>

But when ever user enters this url http://test-site.com should redirect to http://test-site.com/dev/ Could any one please help me in this regard?

CodePudding user response:

With your shown samples, attempts, please try following htaccess rules file. Please make sure to clear your browser cache before testing your URLs. I have also put comments before new rule and before a small fix in existing rule.

<IfModule mod_rewrite.c>
RewriteEngine On
##adding new rule for redirection here...
RewriteRule ^/?$ /dev? [R=301,L]
RewriteBase /dev/
##Added NC flag here for ignore case.
RewriteRule ^index\.php$ - [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/index.php [L]
</IfModule>
  • Related