Showing results for 
Search instead for 
Did you mean: 

Custom URL Rewrite produces 404 error (Magento and Nginx)

Custom URL Rewrite produces 404 error (Magento and Nginx)

I am running Magento on Nginx version 1.9.4. I have URL rewrite configured and turned on and all my product and category URLs  (of type System) seem to work fine. However when I set up a rewrite rule of type Custom, and then access it, it gives me a blank white (no Magento template) 404 error page.


So what I am trying to achieve is this. I am migrating from an old store over to Magento. The old store has listings in google. I simply want to make sure that when someone accesses "" once I switch over to magento, that it will redirect it with a Permanen 301 to "catalog/product/view/id/1". Hope that this makes sense, and hope that this is what the URL rewrite tool inside Magento admin is for.


Again, the other rewrite stuff seems to work just fine. Just this doesn't.


Please let me know what I am doing wrong. Thank you.




Re: Custom URL Rewrite produces 404 error (Magento and Nginx)

hi guy!

same problem for me.

running Magento CE (multilanguage with 2 store view: 1 for Italian and 1 for English language)

mod rewrite enable: yes

I'm trying to redirect the old url (old joomla store with a good google rank) to the new products' urls.

all works fine but this.

I've tried to figure it out and experienced what detailed below:

1. if I set Italian in System -> Store view as 'Sort Order' = 0 and English as 'Sort Order' =1    NO custom urls will work

2. If I set English in Sistem -> Store view as 'Sort Order' = 0 and Italian as 'Sort Order' =1 SOME English customs-urls work but not all of them: anyway NO italian custom URL work.


Any tip / hint will be highly appreciated. I've surfed the web for all the possible solution and tried dozens with no avail.


NOTE: default URLs are working like charm

Have I tried to reindex? yep!

cache? var/cache is empty like my pocket..

Re: Custom URL Rewrite produces 404 error (Magento and Nginx)

Hello romeof, I am telling you all of this had me puzzled. And then I found the solution that worked for me. Now when it comes to your problem I am not sure if I can be of assistance. However since you are getting a 404 error I am almost thinking that the request never even hits Magento. Otherwise it would display the Magento “oops” page. But I am assuming that you are getting just the standard nginx 404 page? This most likely has something to do with the rewrite configuration for nginx. Let me ask you this: Would any of your old URLs, (even in part) exist on your Magento installation? What I am trying to get at is the following. If one of you old URLs is something like , then maybe some rewrite code must go inside your nginx host config file for the app directory? It would help to know how one or some of your old URLs look like. Also I am not sure - but I do hope there is - if there is a way to assign product URLs for each store (in your case language). I am sure there is… Anyway, the key would be that a) nginx knows how to redirect to Magento index.php, and b) all parameters from that request are passed to Magento (including anything after ? and #), and that Magento on the other hand knows what to do with it. I am not too familiar with a multi store setup in Magento. Just trying to give you some food for thought.

Re: Custom URL Rewrite produces 404 error (Magento and Nginx)

Hi Martin,

thanks for taking the time for answering, appreciate it.

well, just to clarify a little better my issue:

1) Running with Apache 2.2.29

2) an example of old URL: en/woodworking-machines/impregnating/impregnating-di0-60

new URL: woodworking-machines/impregnating-machines/impregnating-machine-di0-60.html

(complete new URL: -> no need to add en/ at the beginning because when creating the custom URL I choose Store -> English)

3) I do get the Magento “oops” 404 page (see:


so.. plenty of room for "food for thought" here..  I highly appreciate your help and, of course, I'll keep you up to date.




Re: Custom URL Rewrite produces 404 error (Magento

By the way,

we've restricted a little bit the issue:


It's turning out that the user always land on the default-language page.

If we create 2 custom 301 redirect for product A in the following way:

1) store View English:    Request Path:  product-a-it        Target Path:     new-product-a-en

2) store View Italiano:    Request Path:  product-a-it        Target Path:    new-product-a-it

when we paste the URL in the browser we'd get the user anyway landing on the right product/category and need only to switch language.

the issue remain when clicking on the google page indexing that link: in that case we'd land on the home page no matter of the 2 custom URL.


I haven't seen a nothing about that kind of issue with multilanguage (surfing the web for almost 2 days) and I'm starting to think that it could be more a "conceptual" issue than a "technical" issue.


it's the first time we've to redirect old URL using 301 (cause site migration from an old joomla website) and perhaps we're looking at the problem from a wrong perspective.


if anyone know a good way to accomplish a good 301 redirect in MULTILANGUAGE (having old URLs that clearly need to be redirected to the new ones) and wants to share it.. is more than welcome!

Re: Custom URL Rewrite produces 404 error (Magento

Hello again. So since you are getting an actual Magento 404 not found page, then that means that a) something is redirected with the Apache rewrite b) that it hits Magento c) that Magento does not understand what to do with the request and it shows you a Magento 404 oops page So I can only go with my experience and particular case. I had a problem that all of our old store URLs are in a format like: …. So we were dealing with URL parameters (everything after the ?). So I had to tell Nginx somehow when rewriting the URL to the new magento index.php to always pass along the original URL request with all parameters. For me it was not working because the rewrite in URLs in Nginx ignored the parameters! So that’s where my problem was. Lets try to analyze your problem a bit further.. and again, I am just thinking out loud here because I don’t have access to your store or code. 1. You have a multi store setup 2. store 1 (default) is English and store 2 is Italian 3. You created your store with the English version as default, and then you created another store inside Magento for the Italian Version, and both stores use the same vhost config? 4. you followed the multi language store setup as described here under setup new store view? 5. You can access product A in Magento like in English, and you can access it like in Italian, then technically your store should be set up correctly. I can tell you that in my store my custom URL rewrite looks like this: ID = 14 Type = Custom ID Path = category/product.html (the actual product URL in Magento; needs to be the actual and full URL, so if your full URL has en/ in front you need that too) Request Path = directory/index.php?id=xx&path=yy Target Path = category/product.html Options = RP When I set up this custom URL I first a) Click on “Add URL Rewrite” b) Select “Custom” (and if necessary select which store view it applies to - see instructions here - ) c) Then I entered ID Path, Request Path, Target Path d) Select: Redirect Permanent 301 e) Description - I put some notes in here so I can remember what this is for Now this works for me. Please note that when I request the URL it actually changes the URL in the browser window to the new Magento URL! A 301 is sent back to referrer (Google in that case) letting it know that we are redirecting permanently to the new URL. Please give it another try and see if you have it set up this way.

Re: Custom URL Rewrite produces 404 error (Magento

Hi Martin,

thanks for the answer.

I troubleshooted the issue following what you suggested and I found I set up the store in the right way.

Anyway your "food for thought" take me a little bit closer to the solution.


The problem seems to be the fact that the URL are NOT unique for the Website but they are unique for any Store-View.

Hence, when redirecting, Magento search the address only inside the Sore-view where you currently are (when pasting the address in the URL after the domain name) or searching in the default Sore-View (English for me) if you click a link from outside the website.


So the question is:

how can I set the scope of the URL so it will be unique for the Store-view?

I tried to set the scope of the URL_key attribute (Catalog - Attribute) as Store_view but when I try to add an URL-Rewrite I am only allowed to choose 1 Store-view (I can not select the Website or the Sore: only the View).

I reckon, if I could insert the URL to be redirected as a Website scope I could get the redirect to the right Store-view (remembering that for me a Store-view is used only for multilanguage purposes).



have a great day,


Re: Custom URL Rewrite produces 404 error (Magento

Romeo, Sorry for the delay. I am sorry but it sounds like you are quite a bit more advanced when it comes to Magento setup. I have never set up a multi store setup with Magento. Also I am trying to get this thing to work with Nginx as web server, and you are using Apache. I just discovered another issue. All of my old to new URLs work as long as the old URLs do not include index.php somewhere in the URL string. As soon as there is index.php in the mix (and I am not talking about - which would make sense since this is a physical page for Magento, but I am talking about ?id=something, and I think that this shouldn’t cause a problem, but it does). Nginx’s forwarding is doing it’s job just fine, but as soon as it hits Magento it turns the URL about into and displays the 404 oops page. It’s totally weird. If there is anyone else out there who may have a clue why this is happening please let me know. Thank you.

Re: Custom URL Rewrite produces 404 error (Magento

Hi Martin, it seems that coming from another CMS (Drupal) made me make a mistake when setting up Magento Multilanguage. I just found some good tips here: I'll try it and I'll let you know. I'll take also a look at your issue, just remember that index.php is not displaied if you have Mod_rewrite Enable (for SEO purposes) have a great day, romeo

Re: Custom URL Rewrite produces 404 error (Magento

Thanks so much for looking into my issue. I know you have your work cut out for you. I do understand that index.php would not be displayed in Magento because of the SEO setting inside Magento. So I tried this as a Magento rewrite: first I set it up like this: Incoming URL: This results in Magento changing the URL to and throwing the 404 Then I set it up in Magento rewrite as: Incoming URL: However Magento still throws the 404. I did also try to temporarily rename the magento index.php page and put a placeholder index.php in the root directory. I just wanted to see if Nginx forward this properly, and it does. It showed that temporary test index.php page. So I know Nginx is doing the forwarding, but Magento is not liking the fact that it contains index, or has a /? at the end. So strange but I can kind of see why it would be since I have the Magento SEO enabled. So we would expect that Magento is trying to hide index.php. Grr… Any thoughts?