简体   繁体   中英

Apache2, FastCGI, PHP5 and urls without .php sufix

I have to configure my Apache2 server to host an old web application, based on Joomla 1.5. Apache is running on Debian Stretch, with PHP 7 as mod_php. I manage to install PHP 5.6 as FastCgi module and it looks like working as an alternative to PHP 7.

My VirtualHost looks like this:

<VirtualHost *:80>

  ServerName site.pl

  DocumentRoot /var/www/site/html
  DirectoryIndex index.html index.php

  <FilesMatch ".+\.ph(p[3457]?|t|tml)$">
        SetHandler "proxy:unix:/run/php/php5.6-fpm.sock|fcgi://localhost"
  </FilesMatch>

</Virtualhost>

And it works very well with basic urls, like:

http://site.pl/index.php

The problem is with other urls generated by this old CMS, like:

http://site.pl/index.php/category/page

I get 404 error, obviously.

I don't know how to keep this kind of urls and handle them with FastCgi proxy. What FileMatch cover this url? Any ideas?

The argument in FilesMatch appears to be a regular expression, so you could adapt it to also match URLs generated by the old CMS, for example:

.+\.ph(p[3457]?|t|tml)(/.*)*$

Notice the (/.*)* at the end, which matches the additional path after index.php , but can be omitted, so that URLs without path are also matched.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM