2 Replies - 1009 Views - Last Post: 20 August 2012 - 10:25 AM

#1 JSammy  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 23
  • Joined: 20-April 11

RewriteRule in .htaccess not redirecting

Posted 17 August 2012 - 02:42 PM

Good Afternoon Everyone,

I'm hoping this is a fairly simple problem and that I'm just being daft.
I have a magento store with multiple stores, and obviously multiple domains pointed to it. We recently upgraded our site, and subsequently it broke a lot of old links, that were floating about the interwebs. So, long story short, I need to redirect old URL's to new ones in each domain, within one .htaccess file.

Here's the problem:

within the .htaccess file I am trying to use RewriteRule to direct specific url's (including the root xxxxx.com)
I have a feeling I'm doing this all wrong, so if you could tell me what to change, or point me to someplace I can read up on RewriteRule I would greatly appreciate it.

my current RewriteRule is:
Options +followSymlinks
RewriteEngine on
RewriteRule http://www.domain.net/old-file.html http://www.domain.net/new-file.html

Right now, nothing happens, and the page just goes to the standard 404 page.

Thanks, and Best Regards,

Is This A Good Question/Topic? 0
  • +

Replies To: RewriteRule in .htaccess not redirecting

#2 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: RewriteRule in .htaccess not redirecting

Posted 17 August 2012 - 04:32 PM


The RewriteRule directive only matches the path part of the URL. (The part between the host and the query string.) So if you want to match the host name as well, you'll need to use the RewriteCond directive with it.
RewriteCond %{HTTP_HOST} =domain1.example.com
RewriteRule old-file.html domain1/new-file.html

RewriteCond %{HTTP_HOST} =domain2.example.com
RewriteRule old-file.html domain2/new-file.html

One thing that comes to mind though. Why don't you just use one .htaccess file per store, inside the directory for that store? Should simplify things quite a bit.

And on a related note. How are request being routed to the directories based on domains? Virtual hosts, perhaps? If so, then using one .htaccess file in the parent folder makes little sense. It would be far more sensible to use one .htaccess file per store, or even just define the rewrite rules in the Virtual Host config file.
Was This Post Helpful? 1
  • +
  • -

#3 JSammy  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 23
  • Joined: 20-April 11

Re: RewriteRule in .htaccess not redirecting

Posted 20 August 2012 - 10:25 AM

Thanks, that was very helpful.

Honestly, I would much prefer to use an htaccess file per store, but the layout of magento keeps all the stores together (regrettably). I'm actually looking at RewriteMap's now, since then I could define one RewriteRule and have it check against multiple possible broken links, rather than put a bunch of 301 redirects in the .htaccess file, and slowing the page load time considerably. My only problem is that It doesn't seem to be working.

I have declared the RewriteMap in the virtual host file, and tried to setup the RewriteRule in .htaccess, and in the virtual host file itself. in the htaccess file, i get a 500 error, and when it's in the virtual host file it doesn't seem to do anything...

I'm using a map file that looks like
/old-url.html http://www.domain.net/new-url.html

I'm wondering if my syntax is off. I'll let you know what I find out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1