Redirect to new url using .htaccess

I'm trying to redirect the url, but the way I have the .htaccess file it doesn't seem to work. Is there a specific location or format that I need to use for the redirect?

Below is my .htaccess

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

Redirect 301 /research/report-listings/ http://example.com/research/research-portfolio/

# END WordPress

# BEGIN wtwp_cache
# END wtwp_cache

# BEGIN wtwp_security
# END wtwp_security

      

+3


source to share


2 answers


You probably don't want to mix mod_alias directives with mod_rewrite directives. Both modules will end up being applied to the same request and you might end up with some redirects. It's best to use mod_rewrite if you have rules for things like Wordpress.

Note: order is very important



# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^research/report-listings/(.*)$ http://example.com/research/research-portfolio/$1 [L,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

      

+3


source


Try to put your directive Redirect

inside a block <IfModule mod_alias.c>...</IfModule>

. Then make sure you have installed and enabled mod_alias.c

:



apache2ctl -M  #This is for Linux systems

      

0


source







All Articles