Home > Software design >  Redirect one URL to another using htaccess
Redirect one URL to another using htaccess

Time:12-09

My current .htaccess file code is as follows:

### ISPConfig folder protection begin ###
AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/web113/web/.htpasswd
require valid-user
### ISPConfig folder protection end ###


<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]

</IfModule>

I want to redirect URL as http://xxxxx.xxxxxx.net/local-attraction to http://xxxxx.xxxxx.net/pages/local-attraction

I have tried with

RedirectPermanent http://xxxxx.xxxxxx.net/local-attraction http://xxxxx.xxxxx.net/pages/local-attraction

Also with the

Redirect 301 /local-attraction http://xxxxx.xxxxx.net/pages/local-attraction

But nothing works, it is showing 404 page.

CodePudding user response:

You should use mod_rewrite rule for this redirect since you are already using it your .htaccess:

RewriteEngine On

RewriteRule ^local-attraction/?$ /pages/$0 [L,NC,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
  • Related