我正在运行一个ec2 ubuntu实例,我决定今天更新我的PHP到5.5.7,不幸的是它也触发了apache更新,这也导致了我很多错误,最大的一个是我的重写规则不再被打中,我相信它会改变.conf的东西。
我的网站conf(是的,我的前台和后台网站共享相同的.conf,有点懒,但方便。
<VirtualHost *:80> DocumentRoot /var/www/hivetracking-front/checkout/hive-tracking/public/ ServerName hivetracking.com ServerAlias www.hivetracking.com SetEnv _ENV production <Directory /> DirectoryIndex index.phtml RewriteEngine On LogLevel alert rewrite:trace6 Options Indexes FollowSymLinks AllowOverride All </Directory> ErrorLog /var/www/hivetracking-front/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/www/hivetracking-front/access.log combined </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/hivetracking-back/checkout/hive-tracking-api/public ServerName api.hivetracking.com SetEnv _ENV production <Directory /> DirectoryIndex index.php RewriteEngine On LogLevel alert rewrite:trace6 Options Indexes FollowSymLinks AllowOverride All </Directory> ErrorLog /var/www/hivetracking-back/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/www/hivetracking-back/access.log combined </VirtualHost>
我的.htaccess的API:
RewriteEngine on ServerSignature On DirectoryIndex index.php Options Indexes FollowSymLinks <FilesMatch "\.(ico|pdf|flv)$"> Header set Cache-Control "max-age=29030400, public" #1 YEAR </FilesMatch> <FilesMatch "\.(xml|txt|css|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=172800, proxy-revalidate" #1 WEEK </FilesMatch> <FilesMatch "\.(html|htm|php|js)$"> Header set Cache-Control "max-age=60, private, proxy-revalidate" #2 DAYS </FilesMatch> # system/session RewriteRule ^([-A-Za-z0-9]+)/([-A-Za-z]+)$ index.php?__module=$1&__action=$2 [L,QSA] # teams/something/123456 RewriteRule ([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/([0-9a-fA-F]{24}+)$ index.php?__module=$1&__action=$2&id=$3 [L,QSA] # teams RewriteRule ^([-A-Za-z0-9]+)$ index.php?__module=$1&__action=index [L,QSA] # teams/123456 RewriteRule ([-A-Za-z0-9]+)/([0-9a-fA-F]{24}+)$ index.php?__module=$1&__action=index&id=$2 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
去http://api.mydomain.com/client结果404转到http://api.mydomain.com/index结果404转到http://api.mydomain.com/index.php加载文件
任何帮助非常感谢!
我通过从.htaccess中删除这些来解决这个问题
<FilesMatch "\.(ico|pdf|flv)$"> Header set Cache-Control "max-age=29030400, public" #1 YEAR </FilesMatch> <FilesMatch "\.(xml|txt|css|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=172800, proxy-revalidate" #1 WEEK </FilesMatch> <FilesMatch "\.(html|htm|php|js)$"> Header set Cache-Control "max-age=60, private, proxy-revalidate" #2 DAYS </FilesMatch>
我不知道为什么花了我8小时的debugging来跟踪这个,但错误没有被logging。
在您的configuration文件中searchAllowOverride的所有示例。 可能是已经添加的东西,正在replace上面的configuration中的一个。
其次,在VirtualHost的configuration中,将Directory语句replace为您的文档根目录:
<Directory /var/www/hivetracking-front/checkout/hive-tracking/public> DirectoryIndex index.php RewriteEngine On LogLevel alert rewrite:trace6 Options Indexes FollowSymLinks AllowOverride All </Directory>
这将有助于确保其他内容不会覆盖AllowOverride设置。