3

I'm trying to do a url redirect but the way I have the .htaccess file it doesn't seem to work. Is there a specific place or format 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
spencer.sm
  • 19,173
  • 10
  • 77
  • 88

2 Answers2

3

You probably don't want to mix mod_alias directives with mod_rewrite directives. Both modules will end up getting applied to the same request and you can end up with some wonky redirects. Best to just use mod_rewrite if you've rules for things like Wordpress.

Note: the 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
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • I was about to add to my answer that he should [just use mod_rewrite](http://stackoverflow.com/questions/808014/mod-rewrite-or-mod-alias) since he already has it. – Alex W May 12 '15 at 15:32
0

Try putting your Redirect directive inside of a <IfModule mod_alias.c>...</IfModule> block. Then, make sure you have mod_alias.c installed and enabled:

apache2ctl -M  #This is for Linux systems
Alex W
  • 37,233
  • 13
  • 109
  • 109
  • I tried that and it still doesn't seem to work. When I go to the page it doesn't follow the redirect it just gives me a 404 – spencer.sm May 12 '15 at 15:30
  • [Here's](http://stackoverflow.com/questions/4856193/using-mod-rewrite-and-mod-alias-redirect-301-together-in-htaccess) the same problem you're having. – Alex W May 12 '15 at 15:41