Mobile app version of vmapp.org
Login or Join
Gonzalez347

: 301 redirect behavior in a drupal system I am migrating an older site to a newer one which is using Drupal. As part of this I am trying to setup some 301 redirects to the new pages but

@Gonzalez347

Posted in: #Drupal #Redirects

I am migrating an older site to a newer one which is using Drupal. As part of this I am trying to setup some 301 redirects to the new pages but I am getting some unexpected behavior. I added the following line to my .htaccess file:

redirect 301 /redirect.html www.example.com/newpage

Unfortunately, what happens is that I get taken to:
www.example.com/newpage?q=redirect.html

Which of course doesn't load correctly. Any thoughts?

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Gonzalez347

4 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

We used to Path redirect module for that purpose. It can't handle all powerful things that Mod_rewrite can, but it's done a really nice job for us at preserving old URLs.

10% popularity Vote Up Vote Down


 

@Cofer257

Forget .htaccess. Use the global redirect. It gives you the following:


Checks the current URL for an alias and does a 301 redirect to it if it is not being used.
Checks the current URL for a trailing slash, removes it if present and repeats check 1 with the new request.
Checks access to the URL. If the user does not have access to the path, then no redirects are done. This helps avoid exposing private aliased node's.


It simplifies migration of your website slightly, and probably most important, it makes it simple to look up exactly what is being redirected where. (as there is a user interface for it)

Bonus (imagine clippy popping up here)

You seem to be creating something similar to clean URLs. I think you might be interested in pathauto.

10% popularity Vote Up Vote Down


 

@Shakeerah822

So after a bit of searching, I found the answer here. It is similar to danlefree's but slightly diffrent.

<IFModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

# custom redirects

RewriteRule ^redirect.html$ www.mysite.com/newpage [R=301,L]

# end custom redirects

...
</IFModule>


This seems to get the job done.

10% popularity Vote Up Vote Down


 

@XinRu657

Your other rewrite rules are interfering.

Try the following instead:

RewriteEngine on

RewriteRule ^/redirect.html$ www.mysite.com/newpage [L,R=301]

# ... existing rewrites

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme