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.
Related
I made a website for an sports club in the area. I always ran it on my own server (apache2) when building and testing it and use .htaccess to make some rewrites. Now the website is going live on their server, only problem is they're running on a cgi/fastcgi server...
I'm not that experienced with that kind of IT terms and modifications, so i hope you'll can help me or give me some advice. What is the best way to make the .htaccess work (and the whole website, which also includes php code)? At the moment the website gives an "(IIS 8.5 Detailed Error) HTTP Error 403.14 - Forbidden" error. Also their running PHP7...
Hope somebody can help me!! Thanks!!
.htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# redirect while under construction
RewriteCond %{REMOTE_ADDR} !^my\.ip\.addr\.ess$
RewriteCond %{REQUEST_URI} !construction\.html
RewriteRule ^(.*)$ /construction.html [R=302,L]
# remove .html extensions from the URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
# convert html to php without changing the extension
AddType application/x-httpd-php .htm .html
ErrorDocument 404 /errors/404.html
This has nothing to do with CGI or FastCGI.
.htaccess is an Apache HTTP specific means of configuring your HTTP server.
If you want to configure Microsoft Internet Information Server then you have to use the IIS configuration methods, not Apache configuration methods.
(You are trying to configure three completely different things in your Apache configuration file, so I'm not going to look up detailed instructions for the IIS equivalents of all of them).
I just copied a concrete5 project over to my local box and am trying to get it running on localhost. I had permissions problems at the start so I just ran a sudo chmod 777 -R site which remedied that. I then had problems with clicking a link. Anything besides index.php would result in a 404. So I messed around with the htaccess file. It came in this state:
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php53/lib
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
and I changed it to this:
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php53/lib
</IfModule>
<Directory>
AllowOverride All
</Directory>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
Now, none of that helped. I decided to just disable pretty URLs in the database. I did that and most links work. It looks like some still don't (maybe the ones that are involved in a package. I don't know because I am picking up this project where someone left it). Bear in mind this all works perfectly on the live server at this time with the first .htaccess file I showed.
Any idea as to how to remedy this?
It does sound like you are having an issue with Pretty URLs. The ones that are still not working after you disabled it are likely do cached items like blocks. If you clear you cache your site will likely work without Pretty URLs turned on.
As for why Pretty URLs are not working, I would first make sure that mod_rewrite is enabled. Then you can try a couple of these for the rewrite rule.
RewriteRule ^(.*)$ index.php [L]
RewriteRule .* index.php [L]
Note: you can use the scripts from your admin login to update "pretty URLs". One caution would be is that if you use .htaccess for another purpose on your site.
Try removing the htaccess completely. Rather than deleting it, rename it. Then get into the dashboard directly at /index/dashboard/ , disable pretty urls, disable and clear the cache, and clear your browser cache.
(In general, always disable pretty urls and disable and clear the cache before cloning a site.)
Once everything is working without pretty urls, you can then start re-enabling.
I've just hit this one whilst trying out concrete5 on my home machine (linux/apache).
In my case, the problem appears to have been because I'd installed concrete5 two directory levels beneath the document root (/var/www/html). Initially, I just created the .htaccess file based on the values given when I enabled pretty urls, then hit the "page not found" problem (couldn't even log in.) Eventually, the penny dropped: I edited .htaccess and changed RewriteRule to point to the actual location of the concrete5 index.php relative to /var/www/html.
So in my case, concrete5 is installed into /var/www/html/playpen/public_html - so the new RewriteRule reads:
RewriteRule . playpen/public_html/index.php
and that appears to work.
Hope it helps someone ...
I am working on a site that depends on the following htaccess file to create something of a virtual directory structure by redirecting to an index.php whenever the specified url doesn't exist on the system.
AddHandler php5-script .php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
That seems to work fine on the client's existing server. It invisibly redirects things like domain.com/checkout to domain.com/index.php?p=checkout
My problem is that on my local development environment, this causes any non-existing url like that domain.com/checkout, or even the root domain.com to DOWNLOAD the index.php
If I try to load a specific file that exists in the website such as domain.com/index.php then it parses and displays in the browser properly.
In case it matters, my development environment is configured with a Virtual Host on Zend Server Community Edition.
I suppose you've already configured PHP in your development server for all files with the *.php extension. That means that doing it again in your .htaccess files is not only unnecessary but it can possibly cancel your server's configuration (as it's actually doing). Thus you need to get rid of this line:
AddHandler php5-script .php
The question is why it's there in the first place. I'd expect any PHP-enabled hosting service to be configured by default :-?
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Remove .php extension with .htaccess
I'm trying to hide the .php file extension but for some reason can't get it to work. My latest attempt was the following:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^folder/([a-zA-Z_\-0-9]+)/?$ /folder/$1.php
</IfModule>
I have tried many different variances of code I have found online but still no luck. The .htaccess file is placed within the root directory.
I've used this:
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]
# Redirect external .php requests to extensionless URL
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]
# Resolve .php file for extensionless PHP URLs
RewriteRule ^([^/.]+)$ $1.php [L]
See also: this question
The other option for using PHP scripts sans extension is
Options +MultiViews
Or even just following in the directories .htaccess:
DefaultType application/x-httpd-php
The latter allows having all filenames without extension script being treated as PHP scripts. While MultiViews makes the webserver look for alternatives, when just the basename is provided (there's a performance hit with that however).
1) Are you sure mod_rewrite module is enabled? Check phpinfo()
2) Your above rule assumes the URL starts with "folder". Is this correct? Did you acutally want to have folder in the URL? This would match a URL like:
/folder/thing -> /folder/thing.php
If you actually want
/thing -> /folder/thing.php
You need to drop the folder from the match expression.
I usually use this to route request to page without php (but yours should work which leads me to think that mod_rewrite may not be enabled):
RewriteRule ^([^/\.]+)/?$ $1.php [L,QSA]
3) Assuming you are declaring your rules in an .htaccess file, does your installation allow for setting Options (AllowOverride) overrides in .htaccess files? Some shared hosts do not.
When the server finds an .htaccess file (as specified by
AccessFileName) it needs to know which directives declared in that
file can override earlier access information.
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.