Re: when redirecting, a 0kb file is downloaded

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sincerely
Negin Nickparsa

On Mon, Jan 25, 2016 at 10:54 AM, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
wrote:

> On Mon, 2016-01-25 at 10:17 -0800, Negin Nickparsa wrote:
> > @Richard:
> >
> > Here is the script, it is inside Magento.
> >
> > <?php    require __DIR__ . '/app/Mage.php';    Mage::app();
> > ini_set('memory_limit', '32M');    set_time_limit (0);    $category_id
> > = 4;     $catagory_model =
> > Mage::getModel('catalog/category')->load($category_id);
> > $collection = Mage::getResourceModel('catalog/product_collection');
> > $collection->addCategoryFilter($catagory_model); //category filter
> > $collection->addAttributeToFilter('status',1); //only enabled product
> >   $collection->addAttributeToSelect('url_key');
> > $collection->setStoreId(11);//dealer portal, I did store 1, seems all
> > url keys were not there    echo count($collection)."<br>";
> > foreach ($collection as $_product):?>
> >             <?php echo $_product->getSku();?><a href="<?php echo
> > $_product->getUrlKey();?>"><?php echo
> > ":".$_product->getUrlKey();?></a>
> >             <br>
> >      <?php         $redirect =
> > Mage::getModel('enterprise_urlrewrite/redirect')->getCollection()
> >            ->addFieldToFilter('identifier', "car-audio/" .
> > $_product->getUrlKey())
> > ->addFieldToSelect('redirect_id');         if
> > (!$redirect->getData('redirect_id')) {
> > Mage::getModel('enterprise_urlrewrite/redirect')
> > ->setOptions('RP')                     ->setIdentifier("car-audio/" .
> > $_product->getUrlKey())
> > ->setDescription("car-audio import " . $_product->getSku())
> >          ->setTargetPath($_product->getUrlKey())
> > ->save();         }     endforeach;
> >
> >
> >
> >
> >
> >
> >
> > Sincerely
> > Negin Nickparsa
> >
> > On Sat, Jan 23, 2016 at 3:29 AM, Richard <
> > replies-lists-e7x6-php@xxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > >
> > >
> > > > Date: Friday, January 22, 2016 15:03:11 -0800
> > > > From: Negin Nickparsa <nickparsa@xxxxxxxxx>
> > > >
> > > > This is the weirdest thing could ever happen.
> > > >
> > > > I ran a php script of redirecting about 200 urls with a particular
> > > > category to be sent to product detail pages and they worked fine
> > > > on my local machine which is windows.
> > > >
> > > > our staging server is nginx, so I think it should be from some
> > > > configurations but I cannot figure this out.
> > > >
> > > > Could you please let me know what you think about this?
> > > >
> > > > it will redirect to right page but does not reload the page and
> > > > then download a file with the name of url and the file is 0kb.
> > > >
> > > > it seems that I have the same .htaccess file, but server
> > > > configurations are definitely different.
> > > >
> > > > ​Thanks,
> > > > Negin
> > >
> > > Without seeing any of your script, configurations, logs, or a full
> > > description of what you are doing, it's kind of hard to guess what
> > > might be different between your two instances. Show your work.
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
>
> First, please don't top-post. All the major email apps and web providers
> allow you to post your reply to the bottom :)
>
> Second, I'm not seeing any code here that's responsible for forcing any
> kind of download. Typically this would be done with something like:
>
>
> header('Content-Length: 1234');
> header('Content-Disposition: attachment; filename="downloaded.ext"');
> header('Content-Type: mime/type');
> // then your output which is the file
> // ...
> exit;
>
>
> Thanks,
> Ash
>
> http://www.ashleysheridan.co.uk
>
>
>
> ​Hi Ashley,

sure I'll try to keep that in mind, it is kind of hard for me to remember
it.

I do not think anything is wrong in my script either, That was why I did
not post it in the first place. Per Richard, I sent it.

Unfortunately I do not have server configuration.

I just wanted to know if someone had the same experience, because it is
strange for me that although you write a rewrite url but rewrite would
generate files?????

I thought maybe php module is not running on that particular situation and
it cannot interpret PHP but that was not the case, as I can see the script
gives me the result list of URLs.

I just cannot redirect. That's all.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux