Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 513717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:27:03+00:00 2026-05-13T07:27:03+00:00

So my problem is kinda weird, it only occurs when I test the application

  • 0

So my problem is kinda weird, it only occurs when I test the application offline (on my PC with WampServer), the same code works 100% correctly online.

Here is how I use the helper (just example):

<a href="<?php

echo $this->url(array('module' => 'admin',
                      'controller' => 'index',
                      'action' => 'approve-photo',
                      'id' => $this->escape($a->id),
                      'ret' => urlencode('admin/index/photos')),
                null,
                true);

                            ?>" class="blue">approve</a>

Online, this link works great, it goes to the action which looks similar to this:

public function approvePhotoAction()
{
    $request = $this->getRequest();
    $photos = $this->_getTable('Photos');

    $dbTrans = false;

    try {

        $db = $this->_getDb();
        $dbTrans = $db->beginTransaction();

        $photos->edit($request->getParam('id'),
                      array('status' => 'approved'));

        $db->commit();

    } catch (Exception $e) {
        if (true === $dbTrans) {
            $db->rollBack();
        }
    }

    $this->_redirect(urldecode($request->getParam('ret')));
}

So online, it approves the photo and redirects back to the URL that is encoded as “ret” param in the URL (“admin/index/photos”).

But offline with WampServer I click on the link and get 404 error like this:

Not Found

The requested URL /public/admin/index/approve-photo/id/1/ret/admin/index/photos was not found on this server.

What the hell?

I’m using the latest version of WampServer (WampServer 2.0i [11/07/09]). Everything else works.

Here is my .htaccess file, just in case:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

# Turn off magic quotes
#php_flag magic_quotes_gpc off

I’m using virtual hosts to test ZF projects on my local PC. Here is how I add virtual hosts.

httpd.conf:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName myproject
    DocumentRoot "C:\wamp\www\myproject"
</VirtualHost>

the hosts file:

127.0.0.1    myproject

Any help would be appreciated because this makes testing and debugging projects on my localhost a nightmare and almost impossible task. I have to upload everything online to check if it works 🙁

UPDATE:

Source code of the _redirect helper (built in ZF helper):

/**
 * Set redirect in response object
 *
 * @return void
 */
protected function _redirect($url)
{
    if ($this->getUseAbsoluteUri() && !preg_match('#^(https?|ftp)://#', $url)) {
        $host  = (isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:'');
        $proto = (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=="off") ? 'https' : 'http';
        $port  = (isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:80);
        $uri   = $proto . '://' . $host;
        if ((('http' == $proto) && (80 != $port)) || (('https' == $proto) && (443 != $port))) {
            $uri .= ':' . $port;
        }
        $url = $uri . '/' . ltrim($url, '/');
    }
    $this->_redirectUrl = $url;
    $this->getResponse()->setRedirect($url, $this->getCode());
}

UPDATE 2:

Output of the helper offline:

/admin/index/approve-photo/id/1/ret/admin%252Findex%252Fphotos

And online (the same):

/admin/index/approve-photo/id/1/ret/admin%252Findex%252Fphotos

UPDATE 3:

OK. The problem was actually with the virtual host configuration. The document root was set to C:\wamp\www\myproject instead of C:\wamp\www\myproject\public.

And I was using this htaccess to redirect to the public folder:

RewriteEngine On

php_value upload_max_filesize 15M
php_value post_max_size 15M
php_value max_execution_time 200
php_value max_input_time 200
# Exclude some directories from URI rewriting
#RewriteRule ^(dir1|dir2|dir3) - [L]

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

Damn it I don’t know why I forgot about this, I thought the virtual host was configured correctly to the public folder, I was 100% sure about that, I also double checked it and saw no problem (wtf? am I blind?).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:27:03+00:00Added an answer on May 13, 2026 at 7:27 am
    1. check your php.ini
      php_flag magic_quotes_gpc off Must be Off at online and local servers

    2. do not use urlencode 'ret' => urlencode('admin/index/photos')) because url helper has fourth parameter $encode = true and it is true by default

    3. show us the output of $this->url(array('module' => 'admin'..... at server and at localhost

    i’m using wamp at home and it works like charm

    UPDATE 1
    try $this->_redirect( '/'. ltrim(urldecode($request->getParam('ret')), '/') );

    UPDATE 2;

    ViewScript

        <a href="<?php
    
    echo $this->url(array('module' => 'default',
                      'controller' => 'index',
                      'action' => 'test-encoded-redirect',
                      'ret' => urlencode('default/static/faq')),
                null,
                true);
    
                            ?>">test me</a>
    
    
        <?php
        class IndexController extends Smapp_Controller_Action 
        {   
    
            public function testEncodedRedirectAction()
            {
    
                                // ddump($this->_getAllParams());
                // ddump output 
                // Array ( 
                //  [controller] => index 
                //  [action] => test-encoded-redirect 
                //  [ret] => default%2Fstatic%2Ffaq 
                //  [module] => default 
                // )
    
    
                $ret = '/' . ltrim(urldecode($this->_getParam('ret')), '/');
                // echo $ret;
                // output: /default/static/faq
    
                $this->_redirect($ret);
            }
        }
    

    it works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 279k
  • Answers 279k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer "...where #ics_alert_submit is a button in a jquery generated modal… May 13, 2026 at 3:22 pm
  • Editorial Team
    Editorial Team added an answer In python it helps to think of declaring variables as… May 13, 2026 at 3:22 pm
  • Editorial Team
    Editorial Team added an answer The private field components is used to track disposable components… May 13, 2026 at 3:22 pm

Related Questions

This is kind of a weird question so my title is just as weird.
I've just recently started learning HTML/CSS and I've been trying to teach myself sound
Update Well, as i was told by Stuart Charles and James Gregory, my model
This one has me stumped. I've got a java.sql.ResultSet and I'm pulling string values
I have a server hosting a website of mine that has almost zero-traffic. A

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.