Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I tried making the following change to my wordpress site to permanently redirect a common link to a new page. I could've -sworn- that this used to work. But it simply does not (at least in WP 3.9). I have had to resort to using a Redirect Plug-In.

I'm wondering -why- it doesn't work and if there is a technique which -will- work. I'd prefer to continue to use .htaccess for simplicity.

Below is the .htaccess file:

 # MY CHANGES
 Redirect 301 http://mysite.com/gigs  http://mysite.com/booking/

 # 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>

Again, it works by using a redirect plug-in inside WP, but there must be a way to force the 'redirection' to occur -before- the URL is passed to the WP engine, right? How is the done?

share|improve this question
    
What does happen when you say it "Doesn't work"? Do you mean it just doesn't redirect or is there some other error? I'd disable your redirection plugins in Wordpress before you do any more testing. These can cause some confusion when the redirect happens, as it's impossible to know whether it's the htaccess that is doing the redirect, or has been passed onto Wordpress. –  Luke Peterson Jun 14 at 0:52
    
I mean it simply does not redirect. No error. I have disabled the redirection plug-in. But again, I only added that -after- I made my attempts to use .htaccess. The plug-in taps into the WP redirection system -after- .htaccess is processed. Any ideas? –  jchwebdev Jun 18 at 20:40

2 Answers 2

Your syntax for Redirect is wrong.

  • The first URL should be relative
  • The second URL should be abolute

Try this instead:

Redirect 301 /gigs  http://example.com/booking/
share|improve this answer
    
Doesn't work. Is there any way I can log -why- it fails? –  jchwebdev Jun 13 at 16:31
    
Is there a way to log why it fails? –  jchwebdev Jun 18 at 20:40

To use Redirect you need mod_alias enabled in your apache configuration. If it is not working, it is likely that this module is not enabled.

As you are using mod_rewrite module for redirects already and it is enabled, you should really use RewriteRule:

RewriteRule ^/gigs$ http://example.com/booking/ [R=301,L,NE]
share|improve this answer
    
Tried that. Doesn't work. I've tried that line in just about every position between the <IfModule> section. Any more ideas? –  jchwebdev Jun 18 at 20:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.