I have a site (based on ZEND framework) and hosted on 1and1 server.
1and1 server uses PHP version 5.2.17 and 5.4.5. I need to use PHP version 5.4.5 for a few files only. This is because some of my other files show a errors if I use PHP 5.4.5 but they execute fine using PHP 5.2.17.
On my .htaccess file the line below was written earlier to use PHP 5.2.17
AddType x-mapp-php5 .php
To use PHP 5.4.5 I have to use the the line below (instructions to use this code will be found on the 1and1 faq page)
AddHandler x-mapp-php6 .php
FAQ url(s):
http://faq.1and1.com/scripting_languages_supported/php/7.html
http://faq.1and1.com/scripting_languages_supported/php/6.html
Is there any way to use PHP 5.4.5 for those specific files only?
I tried to use the line below in .htaccess, but it's not working:
AddType x-mapp-php5 .php
AddHandler x-mapp-php6 FilenameController.php
EDIT
I tried to edit the 5.2 code. I am using PEAR packages to create Excel sheet which is working fine with PHP 5.2.17 but displaying the error below on PHP 5.4.5
Fatal error: Cannot redeclare _PEAR_call_destructors()
Addendum
This change to the .htaccess file
AddType x-mapp-php5 .php
AddHandler x-mapp-php6 .php6
SetEnv APPLICATION_ENV development
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^FilenameController\.php$ FilenameController.php6 [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
generates 404 "Page not found" error if I change the filename of FilenameController.php to FilenameController.php6 and when I am trying to visit the page its generating.
Why not just
AddHandler x-mapp-php6 .php6
And rename your 5.4 scripts to php6? You can even hide this from the user by doing the following in your .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^FilenameController\.php$ FilenameController.php6 [L]
This does an internal direction to a .php6 extension for that one script file. :-)
However, let me emphasise: you can only choose which scripting engine to use on a per request basis not on a per file basis. For example: http:/yourdomain.com/FilenameController.php will be handled by the PHP 5.4 RTS and all included files will be compiled and executed using PHP 5.4; http:/yourdomain.com/index.php will be handled by the PHP 5.2 RTS and all included files will be compiled and executed using PHP 5.2.
You can't use 5.4 to compile on file within an application and 5.2 to compile the rest.
1and1 server uses PHP version 5.2.17 and PHP version 5.4.5.
I'd be curious as to the details of this.
Assuming you run php as an Apache module (mod_php), you can only have one version running on the same installation of Apache at a time. Are you sure that your server even allows to use both at the same time? More likely, you can restart Apache and have it run with a different version. If that is the case, you can't really configure your way out of this, lest you want to set up php over cgi.
Related
I am running an old website (decisions.ch) with a php script from Symfony. The script was coded back in 2008 and since then, the page was never updated. It ran very good until a couple of months ago. I assume that the problems were caused with new php settings from the hoster. At the moment, the site runs on PHP 5.6 FCGI.
I think that I should be possible to fix the site with new .htaccess settings as the hoster just lets me update some of the php.ini settings.
My .htaccess looks like this:
#RewriteLog /home/www/web115/log/rewrite.log
#RewriteLogLevel 1
# Used to acces the PHP 52 # !!! USED ONLY ON HOSTSTAR #
AddHandler application/x-httpd-php54 .php
AddHandler application/x-httpd-php7 .php
AddHandler application/x-httpd-php71 .php
Action php /cgi-php52/php
# Access to the admin
RewriteRule ^admin$ admin.php [L]
# So we redirect only some query to the symfony public controller
RewriteCond %{REQUEST_URI} !^.+\.html$ [NC]
RewriteCond %{REQUEST_URI} ^/(kommentare|decision|suchen|erweiterte_suche|entscheide|absolutja|absolutnein|verwechslungsgefahr|keine_verwechslungsgefahr|gleichartige_waren|nicht_gleichartige_waren|verwechselbare_firmen|nicht_verwechselbare_firmen)(.*)$ [NC]
RewriteRule ^.*$ public.php/%1%2 [PT,QSA,L]
Does anybody has a hint where the error could be? I checked this forum with respect to other no input file posts in order to find something. So far, however, I was not successful.
Refer to this article [http://filext.com/faq/fake_file_extensions.php][1]. I have a website which runs in apache (PHP and mysql). I want to display url with .fake extension instead of .php . I want apache to process all the requests with .fake extension as it do with .php. Is it possible by write something into .htaccess file?
You can do this in two ways.
Rewrite URL's to their php counter-part. The files on the server end with .php. You use mod_rewrite to internally rewrite the urls
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.fake$ $1.php [L]
Add a php handler for the fake extension. The files reside with a .fake extension on your server and you tell apache to use the php application to process these files. You send them with the text/html mime type back to the client.
AddHandler application/x-httpd-php .fake
AddType text/html .fake
There is no real reason to do the second approach, unless you want to confuse fellow developers.
I developed a website using Xampp 1.8.3, PHP version 5.5.3 on Windows 7. I have a hosting account to test my website.
The hosting details are:
Apache version 2.4.6
PHP version 5.3.27
MySQL version 5.5.32-cll
Architecture x86_64
Operating system Linux
The password_hash() and verify_password() functions belongs to PHP 5.5 and ofcourse these are not available in the old PHP versions.
To fix this issue, my hosting people asked me to add these lines in .htaccess file.
# Use PHP 5.5
AddType application/x-httpd-php55 .php
Now my .htaccess file on the server looks like this.
# PHP 5.5
AddType application/x-httpd-php55 .php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Is there any issue if my hosting has Linux Operating system and i developed my website on windows 7?
It still does not work after these changes being made by me. I googled a lot but could not find the solution. Please help me and suggest me what is wrong going on. If you want to check my website, here is a link My Website Link
Please help me out. Thanks!
i have windows server 2008(r2) and i installed php and mysql using with Web Platform Installer in that windows.
it seems everything is ok about php and mysql.
now i want to install http://www.phpfreechat.net/ in my server.
after installation i got this error :
mod_rewrite must be enabled server side and correctly configured. "RewriteBase" could be adjusted in server/.htaccess file.
as you know .htaccess file is for linux servers.
what this error mean and how can i fix it?
i think in my server php is working under iis and there is no appache in my serevr, so how can i bypass that error?
i changed the wwwroot permission to EveryOne with no help.
also when i open wwwroot with cuteftp i can not find any permission by right click on every file (properties)
EDIT:
there are some folders in that project like client - server - etc
in server folder .htaccess is like this :
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /path/to/phpfreechat/server
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<Limit OPTIONS GET POST PUT DELETE>
Order allow,deny
Allow from all
</Limit>
thanks in advance
mod_rewrite is for Apache servers. Here you can see how to use rewrite rules for IIS using the URL Rewriting Module.
You should really read this document on how to create new rewrite rules. I don't know whether it supports .htaccess or not, but I don't think so. Just follow the official documentation.
So, when I put in my .htaccess file which contains the following:
# Use PHP5 php.ini as default
AddHandler application/x-httpd-php5 .php
AcceptPathInfo On
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L,QSA]
The server tries to download the PHP file instead of executing it. When I remove the .htaccess file, everything works fine and the PHP files execute.
I'd remove the AddHandler directive. Leave this to the server config.
Everything else looks fine.
It could very well be the AddHandler application/x-httpd-php5 .php
Are you including this because your server is setup to not run PHP5 by default?
I found the issue in the end, I had the entire thing set up correctly. There is a bug in PHP5, that had happened due to some of the discontinuing support of $_SERVER['ORIG_PATH_INFO']. This is not true in windows servers, however in PHP 5.4.2 (Linux Distro) ORIG_PATH_INFO is not supported any more, only PATH_INFO. A report has been made about this. But all is up and running. Thanks for your guys' help and responses.