Hi All,

I am facing problem that suddenly $Server["REDIRECT_URL"] has stopped working properly.
Whenever user search for any no existent page then i have mentioned in .htaccess file to forward it to index.php.
Then in index.php i have used $
Server["REDIRECT_URL"] to find out the URL which was entered by the user. But this is not working and every time it says URL which user entered is index.php.
Earlier this was working fine but something happened and this is not working.
Could you please help and advice?

Regards,
Rajesh

    Can you show us the code in the .htaccess file that does the redirecting?

      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php
      </IfModule>

      I will explain how i have done the coding in brief, I wanted to shield my website's page original URLS from user and instead shown them user friendly URLS. In database, corresponding to these URLS i can get exact physical locations of the files.
      So suppose if i have my website url http://www.ABCDEF.com/Contact/ ,then as this doesnt not exist then as per .htaccess it will be forwarded to index.php file, where i have used $SERVER['REDIRECT_URL'] to get Contact from the URL clicked by user. Then in database i can search the actual physical file corresponding to Contact and show it to the user.
      It was working perfectly for last 1 year but yesterday due to some issues my php-cgi was changed by webhosting company and $
      SERVER['REDIRECT_URL'] has stopped working.
      Any help would be highly appreciated.

      Thanks,

        If PHP is being run as a CGI binary (and not an Apache module) then I don't believe it's possible for you to access such items as $_SERVER['REDIRECT_URL']. When PHP is run as a CGI binary, the parser is executed as a separate process - it's not linked with the Apache worker process in any direct way, thus it can't retrieve some information internal to Apache.

        EDIT: Note that I'm not 100% on this, but this is what my current knowledge and brief testing concludes.

          Thanks for you reply, but i have another question that many other $SERVER variables are working fine like $SERVER['REDIRECT_STATUS'],so why the problem is only with _SERVER['REDIRECT_URL']?
          And yes same code and confirguration on my localhost wamp server is working fine.

          In any case what i can do to resolve this problem?

            6 days later

            to get things going i have used work around getenv('REQUEST_URI') which is working as replacement of $_SERVER['REDIRECT_URL'].

              Any chance you might be wanting $_SERVER['REQUEST_URI']?

                even $_SERVER['REQUEST_URI'] did worked on my webhosting server, but on local machine wamp server it didnt.

                Any idea why?

                  Write a Reply...